Difference between revisions of "JDK"

From CBLFS
Jump to navigationJump to search
(I added the package description from BLFS.)
 
(13 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
{| style="text-align: left; background-color: AliceBlue;"
 
{| style="text-align: left; background-color: AliceBlue;"
|-
+
|-valign="top"
 
!Binary Download:
 
!Binary Download:
| http://java.sun.com/j2se/1.5.0/download.jsp (to download jdk-1_5_0_10-linux-amd64.bin)
+
| http://java.sun.com/j2se/1.5.0/download.jsp (to download the latest version)
|-
+
|-valign="top"
 +
!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)
 +
|-valign="top"
 +
!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<br>
 +
http://svn.cross-lfs.org/svn/repos/patches/jdk/jdk-1.5.0_08-nptl-1.patch<br>
 +
http://svn.cross-lfs.org/svn/repos/patches/jdk/jdk-1.5.0_08-remove_broken_demo-1.patch<br>
 +
http://svn.cross-lfs.org/svn/repos/patches/jdk/jdk-1.5.0_08-remove_fixed_paths-1.patch<br>
 +
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)<br>
 +
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)<br>
 +
http://svn.cross-lfs.org/svn/repos/patches/jdk/jdk-1.5.0_08-fixes-amd61-1.patch (tested only for amd64)
 +
|-valign="top"
 
|}
 
|}
  
The following installation instructions only cover the installation of the 64-bit precompiled binaries.  If you want or need plugins, you must install the 32-bit version on a pure 32-bit or multilib system.
+
{{Blank-Package-Introduction}}
 
 
== 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 [http://www.java.net/jrl.csp Java Research License] or optionally, the [http://java.net/jiul.csp Sun Java Internal Use License]. In addition, the source code is not allowed to be downloaded to some countries, so for users in those countries, the binary is the only option.
 
 
 
You will first need to download and install the binary version of the JDK.
 
 
 
To build from the source, you will also need to download the additional files and patches to complete the source build as ''(we hope to someday have)'' detailed below.
 
  
 
== Dependencies ==
 
== Dependencies ==
  
No packages in order to install the binaries, but read note below in non-multilib section.
+
=== Required (to build from source) ===
 +
* [[X Window System]]
 +
* [[Zip]]
 +
* [[Unzip]]
 +
* [[Cpio]]
 +
* [[ALSA Library]]
 +
* [[Tcsh]]
  
 
== Non-Multilib ==
 
== Non-Multilib ==
Line 28: Line 35:
 
=== Precompiled Binaries ===
 
=== Precompiled Binaries ===
  
'''NOTE:'''
+
{{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.}}
The JDK binary installation script for 64-bit systems has the dynamic linker path hard-coded at /lib64/ld-linux-x86-64.so.2.  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."
 
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."
Line 40: Line 46:
 
To install the JDK binary you will be required to accept the license agreement.  Unpack the JDK binary.
 
To install the JDK binary you will be required to accept the license agreement.  Unpack the JDK binary.
  
   cp -v jdk-1_5_0_10-linux-amd64.bin jdk-mod.bin &&
+
   cp -v jdk-1_5_0_11-linux-amd64.bin jdk-mod.bin &&
 
   chmod +x jdk-mod.bin &&
 
   chmod +x jdk-mod.bin &&
 
   ./jdk-mod.bin
 
   ./jdk-mod.bin
Line 46: Line 52:
 
As the ''root'' user, install the precompiled binaries.
 
As the ''root'' user, install the precompiled binaries.
  
   cd jdk1.5.0_10 &&
+
   cd jdk1.5.0_11 &&
   install -v -d /opt/jdk/jdk-precompiled-1.5.0_10 &&
+
   install -v -d /opt/jdk/jdk-precompiled-1.5.0_11 &&
   mv -v * /opt/jdk/jdk-precompiled-1.5.0_10 &&
+
   mv -v * /opt/jdk/jdk-precompiled-1.5.0_11 &&
   chown -v -R root:root /opt/jdk/jdk-precompiled-1.5.0_10 &&
+
   chown -v -R root:root /opt/jdk/jdk-precompiled-1.5.0_11 &&
 
   ln -v -sf motif21/libmawt.so \
 
   ln -v -sf motif21/libmawt.so \
     /opt/jdk/jdk-precompiled-1.5.0_10/jre/lib/amd64/ &&
+
     /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 ..
 
   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 ===
 
=== Source Build ===
  
TO DONeed smart guy for this.
+
{{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 ==
 
== Multilib ==
  
TO DO. Need smart guy for this.
+
TO DO. (if possible, but it seems that Sun's package can only compile amd64 for 64 bits)
  
 
== Configuration ==
 
== Configuration ==
Line 66: Line 174:
 
Create a link to the directory of the Java you wish to use (precompiled or built from source).   
 
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_10 /opt/jdk/jdk
+
   ln -v -nsf jdk-precompiled-1.5.0_11 /opt/jdk/jdk
  
 
Create an addition to the [[Bash Startup Files]] with the following command:
 
Create an addition to the [[Bash Startup Files]] with the following command:
Line 98: Line 206:
 
  # End /etc/profile.d/30-jdk.sh
 
  # End /etc/profile.d/30-jdk.sh
 
  EOF
 
  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.
 +
 +
[[Category:Programming]]

Latest revision as of 16:00, 19 March 2009

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)

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.

Retrieved from "?title=JDK&oldid=17635"