JDK

From CBLFS
Jump to: navigation, search
Binary Download: http://java.sun.com/j2se/1.5.0/download.jsp (to download the latest version)
Source Download: http://download.java.net/tiger/ (to download jdk-1_5_0_11-fcs-src-b03-jrl-09_nov_2006.jar (or optionally the JIUL version), jdk-1_5_0_11-fcs-bin-b03-jrl-09_nov_2006.jar, and jdk-1_5_0_11-mozilla_headers-b03-unix-09_nov_2006.jar)
Patches Download: http://svn.cross-lfs.org/svn/repos/patches/jdk/jdk-1.5.0_08-gcc4-1.patch

http://svn.cross-lfs.org/svn/repos/patches/jdk/jdk-1.5.0_08-motif_fixes-1.patch
http://svn.cross-lfs.org/svn/repos/patches/jdk/jdk-1.5.0_08-nptl-1.patch
http://svn.cross-lfs.org/svn/repos/patches/jdk/jdk-1.5.0_08-remove_broken_demo-1.patch
http://svn.cross-lfs.org/svn/repos/patches/jdk/jdk-1.5.0_08-remove_fixed_paths-1.patch
http://svn.cross-lfs.org/svn/repos/patches/jdk/jdk-1.5.0_08-remove_debug_image-1.patch (recommanded - skips compiling of the JDK debug image)
http://svn.cross-lfs.org/svn/repos/patches/jdk/jdk-1.5.0_08-static_cxx-1.patch (recommended - forces dynamic linking to GCC libs)
http://svn.cross-lfs.org/svn/repos/patches/jdk/jdk-1.5.0_08-fixes-amd61-1.patch (tested only for amd64)

Contents

Introduction to JDK

Project Homepage: Unknown

Dependencies

Required (to build from source)

Non-Multilib

Precompiled Binaries

Caution.png

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 which is correct according to the SysV processor-specific ABI supplement draft on http://refspecs.freestandards.org/. 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_11-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_11 &&
 install -v -d /opt/jdk/jdk-precompiled-1.5.0_11 &&
 mv -v * /opt/jdk/jdk-precompiled-1.5.0_11 &&
 chown -v -R root:root /opt/jdk/jdk-precompiled-1.5.0_11 &&
 ln -v -sf motif21/libmawt.so \
    /opt/jdk/jdk-precompiled-1.5.0_11/jre/lib/amd64/ &&
 ln -v -sf libjava.so \
    /opt/jdk/jdk-precompiled-1.5.0_11/jre/lib/amd64/libjava_g.so &&
 cd ..

Command Explanations

ln -v -sf libjava.so .../libjava_g.so: This link is needed for the source build, as the precompiled binaries doesn't have this library, which is required during the build.

Source Build

Caution.png

Note

This build is intended only for amd64 machines. No other test has been done, and others architectures will need at least some minor changes.

Save the existing path, and append the recently installed JDK.

 export JAVA_HOME=/opt/jdk/jdk-precompiled-1.5.0_11 &&
 export PATH_HOLD=${PATH} &&
 export PATH=${PATH}:${JAVA_HOME}/bin

The source code is contained in self-extracting jar files. You will need to be in a windowed environment to extract the sources. Create a directory to store the extracted sources. Choose the newly created jdk-build directory when prompted for the target directory.

 mkdir jdk-build &&
 cd jdk-build &&
 for JAR in ../jdk-1_5_0_11*.jar
   do java -jar ${JAR}
 done

Apply all the patches downloaded above:

 for PATCH in ../jdk-1.5.0_08*.patch
   do patch -Np1 -i ${PATCH}
 done

If your X Window System is installed into any prefix other than /usr/X11R6, execute the following command, replacing <PREFIX> with the installation prefix of the X Window System:

 find . -type f -exec sed -i 's@/usr/X11R6@<PREFIX>@g' {} \;

Set/unset some variables which affect the build:

 export ALT_BOOTDIR=${JAVA_HOME} &&
 export CLASSPATH_HOLD=${CLASSPATH} &&
 unset JAVA_HOME CLASSPATH CFLAGS CXXFLAGS LDFLAGS &&
 export ALT_DEVTOOLS_PATH="/usr/bin" &&
 export BUILD_NUMBER="update-11" &&
 export DEV_ONLY=true &&
 export ALT_MOZILLA_HEADERS_PATH=${PWD}/share/plugin/ &&
 export MAKE_VERBOSE=true &&
 export ALT_CACERTS_FILE=${ALT_BOOTDIR}/jre/lib/security/cacerts &&
 export BUILD_MOTIF=true &&
 export SKIP_COMPARE_IMAGES=true &&
 export FASTDEBUG=true

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. -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 some warnings, but, as long as the build doesn't stop, the messages are harmless.

 cd control/make &&
 make &&
 cd ../build/linux-amd64

To test the results, you can run one of the provided demo programs using the newly created java binary. Issue the following commands:

 cd j2sdk-image/demo/jfc/Java2D &&
 ../../../bin/java -jar Java2Demo.jar &&
 cd ../../../..

Now, as the root user, install the JDK:

 cp -v -a j2sdk-image /opt/jdk/jdk-1.5.0_11 &&
 chown -v -R root:root /opt/jdk/jdk-1.5.0_11 &&
 cp -v -a j2sdk-image/man/man1/* /opt/share/man/man1
 ln -v -sf motif21/libmawt.so  /opt/jdk/jdk-1.5.0_11/jre/lib/amd64/

Restore the unprivileged user's environment using the following commands:

 export JAVA_HOME=${ALT_BOOTDIR} &&
 export CLASSPATH=${CLASSPATH_HOLD} &&
 export PATH=${PATH_HOLD} &&
 unset ALT_BOOTDIR CLASSPATH_HOLD ALT_DEVTOOLS_PATH BUILD_NUMBER &&
 unset DEV_ONLY ALT_MOZILLA_HEADERS_PATH INSANE MAKE_VERBOSE &&
 unset ALT_CACERTS_FILE PATH_HOLD

Command Explanations

export ALT_BOOTDIR=${JAVA_HOME}: This variable sets the location of the bootstrap JDK.

export ALT_MOZILLA_HEADERS_PATH=${PWD}/share/plugin/: This tells the build exactly where to find the Mozilla headers. This has changed since the previous version and is not mentioned in the installation documentation included with the package source.

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

export BUILD_NUMBER="update-8": 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 CLASSPATH CFLAGS CXXFLAGS LDFLAGS: These variables cause miscompilation of the build. Never set them.

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

export SKIP_COMPARE_IMAGES=true: Skips some checks related to the distribution version (the package is related to SuSE).

ln -sf motif21/libmawt.so /opt/jdk/jdk-1.5.0_11/jre/lib/amd64/: This fixes linking issues with other applications that expect to find the motif libraries with the other JDK libraries.

Multilib

TO DO. (if possible, but it seems that Sun's package can only compile amd64 for 64 bits)

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_11 /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

The Java plugin is located in $JAVA_HOME/jre/plugin/amd64/ns7/. Make a symbolic link to the file in that directory from your browser(s) plugins directory.

Important: The plugin must be a symlink for it to work. If not, the browsers will crash when you attempt to load a Java application.

Personal tools