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. 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.

Package Information

Additional Downloads

Required Patches

Recommended Patches

Optional Patch

JDK Dependencies

Required (to Build JDK from Source)

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

Installation of JDK

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}

Set/unset some variables which affect the build:

unset JAVA_HOME &&
unset CFLAGS
export ALT_DEVTOOLS_PATH="/usr/bin" &&
export BUILD_NUMBER="blfs-6.1" &&
export DEV_ONLY=true &&
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:


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 DEV_ONLY &&
unset INSANE &&

Command Explanations

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.

Configuring JDK

Configuration Information

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
export JAVA_HOME

# Adjust PATH
pathappend ${JAVA_HOME}/bin PATH

# Auto Java Classpath Updating
# Create symlinks to this directory for auto classpath setting
if [ -z ${CLASSPATH} ]; then

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

# End /etc/profile.d/jdk.sh

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.


Installed Programs: appletviewer, extcheck, idlj, jar, jarsigner, java, javac, javadoc, javah, javap, javaws, jdb, keytool, native2ascii, orbd, policytool, rmic, rmid, rmiregistry, serialver, servertool, and tnameserv
Installed Libraries: $JAVA_HOME/lib/*, $JAVA_HOME/jre/lib/*, and libjavaplugin_oji.so
Installed Directory: /opt/jdk

Short Descriptions


runs Java applets outside of the context of a browser.


checks a specified JAR file for title and version conflicts with any extensions installed in the JDK software.


generates Java bindings from a given IDL file.


combines multiple files into a single JAR archive file.


signs JAR (Java ARchive) files and verifies the signatures and integrity of a signed JAR.


launches a Java application by starting a Java runtime environment, loading a specified class and invoking its main method.


reads class and interface definitions, written in the Java programming language, and compiles them into bytecode class files.


parses the declarations and documentation comments in a set of Java source files and produces a corresponding set of HTML pages describing the classes, interfaces, constructors, methods, and fields.


generates C header and source files that are needed to implement native methods.


disassembles a Java class file.


launches Java application/applets hosted on a network.


is a simple command-line debugger for Java classes.


is a key and certificate management utility.


converts files that contain non-supported character encoding into files containing Latin-1 or Unicode-encoded characters.


is used to enable clients to transparently locate and invoke persistent objects on servers in the CORBA environment.


creates and manages a policy file graphically.


generates stub and skeleton class files for remote objects from the names of compiled Java classes that contain remote object implementations.


starts the activation system daemon.


creates and starts a remote object registry on the specified port on the current host.


returns the serialVersionUID for one or more classes in a form suitable for copying into an evolving class.


provides an ease-of-use interface for application programmers to register, unregister, startup and shutdown a server.


starts the Java IDL name server.

Last updated on 2005-08-01 13:29:19 -0600