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. In addition, the source code cannot be downloaded from some countries, so for users in those countries, the binary is the only option.
If you plan on compiling the JDK source, you will still need to download the binary version to bootstrap the JDK build. You will need to download a total of four files to complete the source build: jdk-1_5_0_03-linux-i586.bin, jdk-1_5_0-src-jrl.zip, jdk-1_5_0-bin-jrl.zip, and jdk-1_5_0-mozilla_headers-unix.zip.
Binary download: http://java.sun.com/j2se/1.5.0/download.jsp
Version used (binary): 1.5.0_03
Download MD5 sum (binary): bc221641fcfdc9268499001326fc8ebb
Source download: http://java.sun.com/j2se/jrl_download.html
Download MD5 sum (source): http://anduin.linuxfromscratch.org/sources/BLFS/SVN/I-K/JDK/jdk-1.5.0.md5sums
Download size (binary): 48.7 MB
Download size (source): 65.7 MB (three .zip files)
Estimated disk space required: 1444 MB
Estimated build time: 33.06 SBU
http://www.linuxfromscratch.org/blfs/downloads/6.1/jdk-1.5.0-gcc_3.4.2+-3.patch
http://www.linuxfromscratch.org/blfs/downloads/6.1/jdk-1.5.0-motif_mkmsgcat-1.patch
http://www.linuxfromscratch.org/blfs/downloads/6.1/jdk-1.5.0-nptl-1.patch
http://www.linuxfromscratch.org/blfs/downloads/6.1/jdk-1.5.0-remove_broken_demo-1.patch
http://www.linuxfromscratch.org/blfs/downloads/6.1/jdk-1.5.0-remove_fixed_paths-1.patch
http://www.linuxfromscratch.org/blfs/downloads/6.1/jdk-1.5.0-remove_debug_image-1.patch (skips compiling of the JDK debug image)
http://www.linuxfromscratch.org/blfs/downloads/6.1/jdk-1.5.0-static_cxx-1.patch (forces dynamic linking to GCC libs)
http://www.linuxfromscratch.org/blfs/downloads/6.1/jdk-1.5.0-xorg-6.8.1-1.patch (only required if building against X.org-6.8.2)
X (XFree86-4.5.0 or X.org-6.8.2), Zip-2.31, UnZip-5.52, cpio-2.6, ALSA-1.0.9, and Tcsh-6.14.00
Both versions will be installed in parallel. You may choose to keep either or both.
Install the precompiled JDK with the following commands:
export VERSION=1.5.0_03 && export MV=`echo $VERSION | cut -d "_" -f 1,1` && export V=`echo ${VERSION} | sed -e "s/\./_/g"` && sed -i "s:^PATH=.*::" jdk-${V}-linux-i?86.bin && chmod -v +x jdk-${V}-linux-i?86.bin && mkdir -v -p bin && ln -v -sf /bin/true bin/more && yes | PATH=$PWD/bin:$PATH ./jdk-${V}-linux-i?86.bin && cd jdk${VERSION}
Now, as the root user:
install -v -d /opt/jdk/jdk-precompiled-${MV} && mv -v * /opt/jdk/jdk-precompiled-${MV} chown -v -R root:root /opt/jdk/jdk-precompiled-${MV}
The binary version is now installed.
If you don't want to compile the source or are not in a position to download the source owing to license restrictions, skip ahead to the configuration section.
Add the recently installed JDK to the path.
export JAVA_HOME=/opt/jdk/jdk-precompiled-${MV} && export PATH=$PATH:${JAVA_HOME}/bin
Unzip the sources:
mkdir jdk-build && cd jdk-build && VERSION=1.5.0 && V=`echo $VERSION | sed -e "s/\./_/g"` && unzip ../jdk-${V}-src-jrl.zip && unzip ../jdk-${V}-bin-jrl.zip && unzip ../jdk-${V}-mozilla_headers-unix.zip
Apply all the patches downloaded above.
for PATCH in ../jdk-1.5.0*.patch do patch -Np1 -i ${PATCH} done
Set/unset some variables which affect the build:
export ALT_BOOTDIR="$JAVA_HOME" && unset JAVA_HOME && unset CLASSPATH unset CFLAGS unset CXXFLAGS unset LDFLAGS export ALT_DEVTOOLS_PATH="/usr/bin" && export BUILD_NUMBER="blfs-6.1" && export DEV_ONLY=true && export ALT_MOZILLA_PATH=$PWD && export INSANE=true && export MAKE_VERBOSE=true && export ALT_CACERTS_FILE=${ALT_BOOTDIR}/jre/lib/security/cacerts
Setting CFLAGS/CXXFLAGS/LDFLAGS is guaranteed to make the build fail. If you are interested in optimizing the build, set OTHER_CFLAGS/OTHER_CXXFLAGS/OTHER_LDFLAGS instead. -O3, even in OTHER_C{,XX}FLAGS, is known to cause a build failure.
Additionally, if you would like to make in parallel, add the following:
export HOTSPOT_BUILD_JOBS=[3]
Build the JDK with the following commands. There will be a lot of messages about missing files that look like errors. These are caused by not meeting the expected build environment (Red Hat). As long as the build doesn't stop, the messages are harmless.
cd control/make && make && cd ../build/linux-i?86
Now, as the root user, install the JDK:
cp -v -a j2sdk-image /opt/jdk/jdk-1.5.0 && chown -v -R root:root /opt/jdk/jdk-1.5.0 && ln -sf motif21/libmawt.so /opt/jdk/jdk-1.5.0/jre/lib/i386/
Restore the unprivileged user's environment using the following commands:
unset VERSION && unset MV && unset V && unset ALT_BOOTDIR && unset ALT_DEVTOOLS_PATH && unset BUILD_NUMBER && unset DEV_ONLY && unset ALT_MOZILLA_PATH && unset INSANE && unset MAKE_VERBOSE && unset ALT_CACERTS_FILE
export ALT_BOOTDIR="$JAVA_HOME": This variable sets the location of the bootstrap JDK.
export ALT_MOZILLA_PATH=$PWD: This tells the build where to find the base directory of the plugin path (which contains the Mozilla headers).
export ALT_DEVTOOLS_PATH="/usr/bin": This changes the location where the build finds the needed executables.
export BUILD_NUMBER="blfs-6.1": This will help you identify the compiled version of the runtime environment and virtual machine by appending this information to the version string.
export DEV_ONLY=true: This command skips compiling the documentation and eliminates a dependency on rpm.
unset JAVA_HOME: This clears the JAVA_HOME variable as recommended by the build instructions.
unset CLASSPATH: This clears the CLASSPATH variable as recommended by the build instructions.
unset CFLAGS/CXXFLAGS...: These variables cause miscompilation of the build. Never set them.
export INSANE=true: The certified platform for the build is Redhat Enterprise Advanced Server 2.1. This variable ensures that all the errors related to compiling on a non-certified platform will be displayed as warnings instead of errors.
export MAKE_VERBOSE=true: Allows the compiler commands to be displayed on the console.
export ALT_CACERTS_FILE...: Specifies the certificate file to use (from the installed binary JDK).
ln -sf motif21/libmawt.so /opt/jdk/jdk-1.5.0/jre/lib/i386/: This fixes linking issues with other applications that expect to find the motif libraries with the other JDK libraries.
There are now two Java 2 SDKs installed in /opt/jdk. You should decide on which one you would like to use as the default. For example if you decide to use the source compiled JDK, do the following as the root user:
ln -v -nsf jdk-1.5.0 /opt/jdk/jdk
Add the following jdk.sh shell startup file to the /etc/profile.d directory with the following commands as the root user:
cat > /etc/profile.d/jdk.sh << "EOF" # Begin /etc/profile.d/jdk.sh # Set JAVA_HOME directory JAVA_HOME=/opt/jdk/jdk export JAVA_HOME # Adjust PATH pathappend ${JAVA_HOME}/bin PATH # 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/jdk.sh EOF
The Java plugin is located in $JAVA_HOME/jre/plugin/i?86/ns7/. Make a symbolic link to the file in that directory from your browser(s) plugins directory.
The plugin must be a symlink for it to work. If not, the browsers will crash when you attempt to load a Java application.
Last updated on 2005-08-01 13:29:19 -0600