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 also download the Mozilla headers package available at the same location.

Package information

  • Download (HTTP): http://freshmeat.net/projects/sunjdk

  • Version used (binary): 1.4.2_03

  • Download size (binary): 35 MB

  • Download size (source): 77 MB

  • Estimated Disk space required: 1810 MB

  • Estimated build time: 85 SBU

J2SDK dependencies

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:

VERSION=1.4.2_03 &&
MV=`echo $VERSION | cut -d "_" -f 1,1` &&
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} &&
install -d /opt/j2sdk/j2sdk-precompiled-${MV} &&
mv * /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 postition to download the source owing to license restrictions, skip ahead to the configuration section.

Add the recently compiled JDK to the path.

export JAVA_HOME=/opt/j2sdk/j2sdk-precompiled-${MV} &&
export PATH=$PATH:${JAVA_HOME}/bin

Unzip the source:

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 fix-inline-asm-1 gcc33-1 motif-mkmsgcat \
             remove-debug-image remove-fixed-paths-1 \
             static_cxx
do
   patch -Np1 -i j2sdk-1.4.2-$PATCH.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
[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 ../../..

Make and Install 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 ../.. &&
cd control/build/linux-i?86 &&
cp -a j2sdk-image /opt/j2sdk/j2sdk-1.4.2

Command explanations

export ALT_BOOTDIR="$JAVA_HOME": This var sets 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 eliminates 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

We have two Java 2 SDK's installed in /opt/j2sdk. 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.

Handling CLASSPATH

When compiling packages, the CLASSPATH environment variable is used by 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

The J2SDK package contains appletviewer, extcheck, idlj, jar, jarsigner, java, javac, javadoc, javah, javap, jdb, keytool, native2ascii, orbd, policytool, rmic, rmid, rmiregistry, rmiregistry, serialver, servertool and tnameserv.

Description

appletviewer

appletviewer runs Java applets outside of the context of a browser.

extcheck

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

idlj

idlj generates Java bindings from a given IDL file.

jar

jar combines multiple files into a single JAR archive file.

jarsigner

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

java

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

javac

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

javadoc

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

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

javap

javap disassembles a Java class file.

jdb

jdb is a simple command-line debugger for Java classes.

keytool

keytool is a key and certificate management utility.

native2ascii

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

orbd

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

policytool

policytool creates and manages a policy file graphically.

rmic

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

rmid

rmid starts the activation system daemon.

rmiregistry

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

serialver

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

servertool

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

tnameserv

tnameserv starts the Java IDL name server.