J2SDK-1.4.2

Introduction to J2SDK

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

The source package requires registration at the Sun developer site and accepting the Sun Community Source License. The source code cannot be downloaded from some countries, so for users from those countries, the binary may be the only option.

Even if you plan on compiling the JDK source, you will need to download the binary version to bootstrap the JDK build. Follow the link below to download both source and binary packages. When downloading the source (two files required), also download the Mozilla headers package available at the same location. To build from source, you'll end up downloading a total of four files.

Package information

J2SDK dependencies

Required (to build J2SDK from source)

X (XFree86-4.4.0 or X.org-6.8.2), Zip-2.31, UnZip-5.51, cpio-2.6, ALSA-1.0.7, Tcsh-6.13.00 and GCC-3.3.4

Installation of J2SDK

Both versions will be installed in parallel. You may choose to keep either or both.

Installation of the precompiled JDK is easy: create a directory to install from, copy the .bin there, and run the following commands:

export VERSION=1.4.2_07 &&
export MV=`echo $VERSION | cut -d "_" -f 1,1` &&
export V=`echo ${VERSION} | sed -e "s/\./_/g"` &&
sed -i "s:^PATH=.*::" j2sdk-${V}-linux-i?86.bin &&
chmod +x j2sdk-${V}-linux-i?86.bin &&
mkdir -p bin &&
ln -sf /bin/true bin/more &&
yes | PATH=$PWD/bin:$PATH ./j2sdk-${V}-linux-i?86.bin &&
cd j2sdk${VERSION}

Now, as the root user:

install -d /opt/j2sdk/j2sdk-precompiled-${MV} &&
mv * /opt/j2sdk/j2sdk-precompiled-${MV}
chown -R root:root /opt/j2sdk/j2sdk-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/j2sdk/j2sdk-precompiled-${MV} &&
export PATH=$PATH:${JAVA_HOME}/bin

Unzip the sources:

mkdir j2sdk-build &&
cd j2sdk-build &&
VERSION=1.4.2 &&
V=`echo $VERSION | sed -e "s/\./_/g"` &&
unzip ../j2sdk-${V}-src-scsl.zip &&
unzip ../j2sdk-${V}-mozilla_headers-unix.zip &&
unzip ../j2sdk-${V}-bin-scsl.zip

Apply all the patches downloaded above.

for PATCH in ../j2sdk-1.4.2*.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-`date +%s`" &&
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
export PATH_HOLD=$PATH
export PATH=/opt/gcc-3.3.4/bin:$PATH
[Warning]

Warning

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.

Additionally, if you would like to make in parallel, add the following (adjust MAKE_PARALLEL to your liking):

export HOTSPOT_BUILD_JOBS=$MAKE_PARALLEL

If the included Motif doesn't build properly, the error is noticed much later in the build. A solution is to build the Motif library before compiling the J2SDK.

cd motif/lib/Xm &&
make &&
cd ../../..

Build J2SDK with the following commands. There will be a lot of messages about missing files that look like errors. As long as the build doesn't stop, the messages are harmless, so ignore them.

cd control/make &&
make &&
cd ../build/linux-i?86

Now, as the root user, install J2SDK:

cp -a j2sdk-image /opt/j2sdk/j2sdk-1.4.2 &&
chown -R root:root /opt/j2sdk/j2sdk-1.4.2

Restore the 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 PATH=$PATH_HOLD &&
unset PATH_HOLD

Command explanations

export ALT_BOOTDIR="$JAVA_HOME": This var sets the location of the bootstrap JDK.

export ALT_MOZILLA_PATH=$PWD: This sets the variable that points to where you unzipped the Mozilla headers.

export ALT_DEVTOOLS_PATH="/usr/bin": This changes the location where the build finds the needed executables.

export BUILD_NUMBER="blfs-`date +%s`": This will help you identify this compiled version of the runtime environment and virtual machine by appending this information to the version in the output to java -version.

export DEV_ONLY=true: This command eliminates compiling the documentation and a dependency for rpm.

unset JAVA_HOME: This clears the JAVA_HOME variable as recommended by the build instructions.

unset CLASSPATH: This clears the CLASSPATH variable as per the recommendations in the build instructions.

unset CFLAGS...: These flags cause miscompilation of the build. Never set these.

export INSANE=true: Unless you specify that you are insane the build will not proceed. The certified platform for the build is Redhat 6.1. The above variable ensures that all the errors related to compiling on a non-certified platform will be converted to warnings.

export MAKE_VERBOSE=true: Allows the current compilation command to be displayed on the console.

export ALT_CACERTS_FILE...: Specifies the certificate file to use.

Configuring J2SDK

Configuration Information

There are now two Java 2 SDK's installed in /opt/j2sdk. You should decide on which one you would like to use as the default. For example if you decide to use the source compiled J2SDK, do the following:

ln -nsf j2sdk-1.4.2 /opt/j2sdk/j2sdk

Add the following lines to your shell startup file (e.g., /etc/profile).

export JAVA_HOME=/opt/j2sdk/j2sdk
export PATH=$PATH:$JAVA_HOME/bin

Add $JAVA_HOME/man to your MANPATH variable or to /etc/man.conf

The Java plugin is in the directory $JAVA_HOME/jre/plugin/i?86/ns610/. Make a symbolic link to the file in that directory from your plugins directory. Note that the plugin must be a symlink for it to work. If not, the browsers just crash when you attempt to load a Java plugin.

Handling CLASSPATH

When compiling packages, the CLASSPATH environment variable is used by the JDK to locate classes at compile-time and run-time. It is tedious to add all the classes used to the CLASSPATH manually. You may add the following lines to your shell startup file to set CLASSPATH automatically to include all JAR files in a specified directory, which in the example below is /usr/lib/auto-java-classpath.

AUTO_CLASSPATH_DIR=/usr/lib/auto-java-classpath
if [ -z $CLASSPATH ]
then
  CLASSPATH=.:$AUTO_CLASSPATH_DIR
else
  CLASSPATH=$CLASSPATH:.:$AUTO_CLASSPATH_DIR
fi
for i in $(ls $AUTO_CLASSPATH_DIR/*.jar 2>/dev/null)
do
  CLASSPATH=$CLASSPATH:$i
done

Contents

Installed Programs: appletviewer, extcheck, idlj, jar, jarsigner, java, javac, javadoc, javah, javap, 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/j2sdk

Short Descriptions

appletviewer

runs Java applets outside of the context of a browser.

extcheck

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

idlj

generates Java bindings from a given IDL file.

jar

combines multiple files into a single JAR archive file.

jarsigner

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

java

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

javac

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

javadoc

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.

javah

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

javap

disassembles a Java class file.

jdb

is a simple command-line debugger for Java classes.

keytool

is a key and certificate management utility.

native2ascii

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

orbd

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

policytool

creates and manages a policy file graphically.

rmic

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

rmid

starts the activation system daemon.

rmiregistry

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

serialver

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

servertool

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

tnameserv

starts the Java IDL name server.

Last updated on 2005-02-26 22:37:02 -0700