%general-entities; ]> $LastChangedBy: randy $ $Date: 2008-05-10 13:50:47 -0500 (Sat, 10 May 2008) $ JDK-&jdk-version; JDK 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. You will first need to download and install the binary version of the JDK (you'll need to click and agree to the Sun Microsystems, Inc. Binary Code License Agreement). To build from the source, you will need to read, and agree to the Sun Java Research License. You will also need to download the additional files and patches to complete the source build as detailed below. Note that in some countries you cannot download the source code. Sun has recently decided not to provide JRL sources for the latest update versions of the JDK. The source build instructions and patches are here for reference only, and contain known security vulnerabilities. For more information, please see Sun Alerts 231246, 233321, 233322, 233323, 233324, 233325, 233326, and 233327. Sun is actively working on a GPL'd version of the JDK, titled OpenJDK. This new JDK will be licensed under the GNU General Public License, version 2, with the Classpath Exception. A stable OpenJDK was not available at the time of writing. Binary Package Information Binary download (jdk-&jdk-bin-version;-linux-i586.bin): Download MD5 sum: &jdk-bin-md5sum; Download size (binary): &jdk-bin-size; Estimated disk space required: &jdk-bin-buildsize; Source Package Information JRL Source &jdk-source-jrl-md5sum; &jdk-source-jrl-size; Source Binaries &jdk-source-bin-md5sum; &jdk-source-bin-size; Mozilla Headers &jdk-source-moz-md5sum; &jdk-source-moz-size; Estimated disk space required: &jdk-src-buildsize; Estimated build time: &jdk-time; Additional Downloads Required Patches JDK Dependencies Optional Runtime Dependencies (for binary installation) , , and Additional Requirements (for source build, including optional requirements) , , , , and User Notes: Installation of JDK The instructions below install both the binary and source versions. You may stop after installing the binary version or continue on installing the source version. You can choose to keep either or both. The ./jdk-&jdk-bin-version;-linux-i586.bin command below unpacks the distribution into a jdk&jdk-bin-version-string; directory. You will be required to view, and then accept (by entering a y keypress), a license agreement before any files are unpacked. If you are scripting (automating) the build, you'll need to account for this. There is information about automating build commands in the section of Chapter 2. Towards the end of this section, specific information for automating this type of installation is discussed. Normally in BLFS, the files are unpacked into a subdirectory and the starting point for the installation procedures is that location. For this application only, start in the directory where all the downloaded files are located. Install the binary JDK with the following commands: chmod 755 jdk-&jdk-bin-version;-linux-i586.bin && ./jdk-&jdk-bin-version;-linux-i586.bin The installation will end with a message "./jdk-&jdk-bin-version;-linux-i586.bin: line 43: 20283 Aborted" as javaprefix is unset in the environment. This is by design as GTK+ may not be installed during the installation, however, the installation will still exit with a zero error value if scripting the build. Now, as the root user: cd jdk&jdk-bin-version-string; && install -v -m755 -d /opt/jdk-bin-&jdk-bin-version; && mv -v * /opt/jdk-bin-&jdk-bin-version; && chown -v -R root:root /opt/jdk-bin-&jdk-bin-version; && ln -v -sf xawt/libmawt.so \ /opt/jdk-bin-&jdk-bin-version;/jre/lib/i386/ && cd .. Recent versions of libX11 break libmawt when used with the Xinerama extension. While still the root user, apply the following sed to the installed binary to work around this problem: sed -i 's@XINERAMA@FAKEEXTN@g' \ /opt/jdk-bin-&jdk-bin-version;/jre/lib/i386/xawt/libmawt.so 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. Save the existing path, and append the recently installed JDK. export JAVA_HOME=/opt/jdk-bin-&jdk-bin-version; && 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-&jdk-version-string;*.jar do java -jar ${JAR} done Apply all the patches downloaded above: for PATCH in ../jdk-&jdk-version-string;*.patch do patch -Np1 -i ${PATCH} done Use the following commands to apply some minor changes that are a little more specific to BLFS, such as lack of a gcc-2.9 compiler, removing a broken demo, and forcing to link to shared libraries. See the 'Command Explanations' section for more detail: sed -i '/^.*linux)/ { N; /.*/ { N; /.*/d }}' \ deploy/make/plugin/{adapter,nscore}/Makefile && sed -i '/.*mtrace.*/ { N; /.*/ s/.*mtrace.*\n.*/\t mtrace/ }' \ j2se/make/mkdemo/jvmti/Makefile && sed -i 's/= true/= false/' \ j2se/make/common/shared/Compiler-gcc.gmk Set/unset some variables which affect the build: export ALT_BOOTDIR=${JAVA_HOME} && export CLASSPATH_HOLD=${CLASSPATH} && export ALT_CACERTS_FILE=${ALT_BOOTDIR}/jre/lib/security/cacerts && export ALT_MOZILLA_HEADERS_PATH=${PWD}/share/plugin && export MILESTONE="03-BLFS" && export BUILD_NUMBER="b05" && export INSANE=true && export DEV_ONLY=true && export SKIP_FASTDEBUG_BUILD=true && unset JAVA_HOME CLASSPATH CFLAGS CXXFLAGS LDFLAGS 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 a few 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. pushd control/make && make && popd To test the results, you can run one of the provided demo programs using the newly created java binary. Issue the following commands: pushd control/build/linux-i586/j2sdk-image/demo/jfc/Java2D && ../../../bin/java -jar Java2Demo.jar && popd Now, as the root user, install the JDK: pushd control/build/linux-i586 && cp -v -a j2sdk-image /opt/jdk-&jdk-version-string; && chown -v -R root:root /opt/jdk-&jdk-version-string; && ln -v -sf xawt/libmawt.so /opt/jdk-&jdk-version-string;/jre/lib/i386/ && popd Restore the unprivileged user's environment using the following commands: export JAVA_HOME=${ALT_BOOTDIR} && export CLASSPATH=${CLASSPATH_HOLD} && export PATH=${PATH_HOLD} && unset PATH_HOLD ALT_BOOTDIR CLASSPATH_HOLD \ ALT_CACERTS_FILE ALT_MOZILLA_HEADERS_PATH \ BUILD_NUMBER MILESTONE INSANE DEV_ONLY \ SKIP_FASTDEBUG_BUILD Command Explanations sed -i '/^.*linux)/...: This command disables the build of a gcc-2.9 compatible browser plugin. LFS does not contain gcc-2.9, and hasn't in quite a few years. sed -i '/.*mtrace.*/...: This command disables building of the broken 'waiters' demo. sed -i 's/= true/= false/'...: This command forces the compiler to link against the standard C libraries dynamically. export ALT_BOOTDIR=${JAVA_HOME}: This variable sets the location of the bootstrap JDK. export ALT_CACERTS_FILE...: Specifies the certificate file to use (from the installed binary 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 MILESTONE="03-BLFS": This appends the string '03-BLFS' to the buld number. 'internal' is unconditionally added if MILESTONE is unset. This is similar to the format used by Sun for the official release. export BUILD_NUMBER="b05": This will help you identify the compiled version of the runtime environment and virtual machine by appending this information to the version string. This is the same build number used by Sun to identify the official release. 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 DEV_ONLY=true: This command skips compiling the comparison build. export SKIP_FASTDEBUG_BUILD=true: This command skips building of the debug version. Omit this command if you need to build the fastdebug target. unset JAVA_HOME CLASSPATH CFLAGS CXXFLAGS LDFLAGS: These variables cause miscompilation of the build. Never set them. ln -sf xawt/libmawt.so /opt/jdk-&jdk-version-string;/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. You should decide on which one you would like to use as the default. For example if you decide to use the precompiled JDK, do the following as the root user: ln -v -nsf jdk-bin-&jdk-bin-version; /opt/jdk The information below assumes your system is set up using the instructions found in . You may need to extract the relevant information below and incorporate it into your system's startup files if your system is set up differently. 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 JAVA_HOME=/opt/jdk # Adjust PATH pathappend ${JAVA_HOME}/bin PATH # Auto Java CLASSPATH # Copy jar files to, or create symlinks in this directory AUTO_CLASSPATH_DIR=/usr/lib/classpath pathprepend . CLASSPATH for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do pathappend $dir CLASSPATH done export JAVA_HOME CLASSPATH unset AUTO_CLASSPATH_DIR unset dir # End /etc/profile.d/jdk.sh EOF 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. Contents Installed Programs Installed Libraries Installed Directory appletviewer, apt, extcheck, idlj, HtmlConverter, jar, jarsigner, java, javac, javadoc, javah, javap, java-rmi.cgi, javaws, jconsole, jdb, jhat, jinfo, jmap, jps, jrunscript, jsadebugd, jstack, jstat, jstatd, keytool, native2ascii, orbd, pack200, policytool, rmic, rmid, rmiregistry, schemagen, serialver, servertool, tnameserv, unpack200, wsgen, wsimport, and xjc $JAVA_HOME/lib/*, $JAVA_HOME/jre/lib/*, and libjavaplugin_oji.so /opt/jdk-&jdk-version-string; Short Descriptions appletviewer runs Java applets outside of the context of a browser. appletviewer apt is an annotation processing tool. apt extcheck checks a specified jar file for title and version conflicts with any extensions installed in the JDK software. extcheck HtmlConverter adds Java auto download to html and asp pages. HtmlConverter idlj generates Java bindings from a given IDL file. idlj jar combines multiple files into a single jar archive. jar jarsigner signs jar files and verifies the signatures and integrity of a signed jar file. jarsigner java launches a Java application by starting a Java runtime environment, loading a specified class and invoking its main method. java javac reads class and interface definitions, written in the Java programming language, and compiles them into bytecode class files. javac 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. javadoc javah generates C header and source files that are needed to implement native methods. javah javap disassembles a Java class file. javap java-rmi.cgi is the Java RMI client. java-rmi.cgi javaws launches Java application/applets hosted on a network. javaws jconsole is a graphical console tool to monitor and manage both local and remote Java applications and virtual machines. jconsole jdb is a simple command-line debugger for Java classes. jdb jhat parses a java heap dump file and allows viewing in a webbrowser. jhat jinfo prints Java configuration information for a given Java process, core file, or a remote debug server. jinfo jmap prints shared object memory maps or heap memory details of a given process, core file, or a remote debug server. jmap jps lists the instrumented JVMs on the target system. jps jrunscript is a command line script shell. jrunscript jsadebugd attaches to a Java process or core file and acts as a debug server. jsadebugd jstack prints Java stack traces of Java threads for a given Java process, core file, or a remote debug server. jstack jstat displays performance statistics for an instrumented JVM. jstat jstatd is an RMI server application that monitors for the creation and termination of instrumented JVMs. jstatd keytool is a key and certificate management utility. keytool native2ascii converts files that contain non-supported character encoding into files containing Latin-1 or Unicode-encoded characters. native2ascii orbd is used to enable clients to transparently locate and invoke persistent objects on servers in the CORBA environment. orbd pack200 is a Java application that transforms a jar file into a compressed pack200 file using the Java gzip compressor. pack200 policytool creates and manages a policy file graphically. policytool rmic generates stub and skeleton class files for remote objects from the names of compiled Java classes that contain remote object implementations. rmic rmid starts the activation system daemon. rmid rmiregistry creates and starts a remote object registry on the specified port on the current host. rmiregistry schemagen is a Java XML binding schema generator. schemagen serialver returns the serialVersionUID for one or more classes in a form suitable for copying into an evolving class. serialver servertool provides an ease-of-use interface for application programmers to register, unregister, startup and shutdown a server. servertool tnameserv starts the Java IDL name server. tnameserv unpack200 is a native implementation that transforms a packed file produced by pack200 into a jar file. unpack200 wsgen generates JAX-WS portable artifacts used in JAX-WS web services. wsgen wsimport generates JAX-WS portable artifacts. wsimport xjc is a Java XML binding compiler. xjc