JDK

From CBLFS
Revision as of 15:05, 5 December 2006 by Weibullguy (talk | contribs) (Added link to source (for the smart guy to use).)
Jump to navigationJump to search
Binary Download: http://java.sun.com/j2se/1.5.0/download.jsp (to download jdk-1_5_0_10-linux-amd64.bin)
Source Download: http://download.java.net/tiger/ (to download jdk-1_5_0_10-fcs-src-b03-jrl-09_nov_2006.jar (or optionally the JIUL version), jdk-1_5_0_10-fcs-bin-b03-jrl-09_nov_2006.jar, and jdk-1_5_0_10-mozilla_headers-b03-unix-09_nov_2006.jar)

The following installation instructions only cover the installation of the 64-bit precompiled binaries. If you want or need plugins, you must install the 32-bit version on a pure 32-bit or multilib system.

Introduction to JDK

The JDK package contains Sun's Java development environment. This is useful for developing Java programs and provides the runtime environment necessary to run Java programs. It also includes a plug-in for browsers so that they can be Java aware.

The JDK comes in two flavors, a precompiled binary and a source package. Previously, the plugin included in the JDK binary package was unusable on LFS owing to incompatibilities with GCC-3 compiled browsers. This is not the case anymore.

In order to use the source code and patches, you must read and agree to the Sun Java Research License or optionally, the Sun Java Internal Use License. In addition, the source code is not allowed to be downloaded to some countries, so for users in those countries, the binary is the only option.

You will first need to download and install the binary version of the JDK.

To build from the source, you will also need to download the additional files and patches to complete the source build as (we hope to someday have) detailed below.

Dependencies

No packages in order to install the binaries, but read note below in non-multilib section.

Non-Multilib

Precompiled Binaries

NOTE: The JDK binary installation script for 64-bit systems has the dynamic linker path hard-coded at /lib64/ld-linux-x86-64.so.2. If installing on a pure 64-bit system the dynamic linker will be installed in /lib. Changing this path manually or with a sed in the *.bin corrupts the *.bin and the install will fail. It is necessary to create a /lib64 directory and a symlink to /lib/ld-2.4.so before attempting to unpack and install the Java binary.

It appears that this link MUST REMAIN after installing the Java binaries. Removing it and attempting to execute any of the Java programs results in "No such file or directory."

If you have a Pure64 system create a link so the path to ld.so is correct:

 mkdir -v /lib64 &&
 ln -sv /lib/ld-2.4.so /lib64/ld-linux-x86-64.so.2

To install the JDK binary you will be required to accept the license agreement. Unpack the JDK binary.

 cp -v jdk-1_5_0_10-linux-amd64.bin jdk-mod.bin &&
 chmod +x jdk-mod.bin &&
 ./jdk-mod.bin

As the root user, install the precompiled binaries.

 cd jdk1.5.0_10 &&
 install -v -d /opt/jdk/jdk-precompiled-1.5.0_10 &&
 mv -v * /opt/jdk/jdk-precompiled-1.5.0_10 &&
 chown -v -R root:root /opt/jdk/jdk-precompiled-1.5.0_10 &&
 ln -v -sf motif21/libmawt.so \
    /opt/jdk/jdk-precompiled-1.5.0_10/jre/lib/amd64/ &&
 cd ..

Source Build

TO DO. Need smart guy for this.

Multilib

TO DO. Need smart guy for this.

Configuration

Create a link to the directory of the Java you wish to use (precompiled or built from source).

 ln -v -nsf jdk-precompiled-1.5.0_10 /opt/jdk/jdk

Create an addition to the Bash Startup Files with the following command:

cat > /etc/profile.d/30-jdk.sh << "EOF"
# Begin /etc/profile.d/30-jdk.sh

# Set JAVA_HOME directory
JAVA_HOME=/opt/jdk/jdk
export JAVA_HOME

# Adjust PATH
export PATH="${PATH}:${JAVA_HOME}/bin"

# Auto Java Classpath Updating
# Create symlinks to this directory for auto classpath setting
AUTO_CLASSPATH_DIR=/usr/lib/classpath
if [ -z ${CLASSPATH} ]; then
  CLASSPATH=.:${AUTO_CLASSPATH_DIR}
else
  CLASSPATH="${CLASSPATH}:.:${AUTO_CLASSPATH_DIR}"
fi

# Check for empty AUTO_CLASSPATH_DIR
ls ${AUTO_CLASSPATH_DIR}/*.jar &> /dev/null &&
for i in ${AUTO_CLASSPATH_DIR}/*.jar
  do CLASSPATH=${CLASSPATH}:"${i}"
done
export CLASSPATH

# End /etc/profile.d/30-jdk.sh
EOF