OpenJDK-1.7.0.9

Introduction to OpenJDK and IcedTea

IcedTea provides a build harness for the OpenJDK package, Oracle's open-sourced Java development environment. In order to provide a completely free runtime environment, similar to Oracle's closed distribution, the IcedTea build harness also provides free, and arguably better versions of parts of the JDK which have not been open-sourced to date. OpenJDK is useful for developing Java programs and provides a complete runtime environment to run Java programs.

This package is known to build and work properly using an LFS-7.2 platform.

[Note]

Note

The browser plugin and webstart implementation have been split off into a separate project. To provide a complete implementation, you will need to later install IcedTea-Web-1.3.

OpenJDK is GPL'd code, however, it should be explained that there has been a special exception made for non-free projects to use these classes in their proprietary products. In similar fashion to the LGPL, which allows non-free programs to link to libraries provided by free software, the GNU General Public License, version 2, with the Classpath Exception allows third party programs to use classes provided by free software without the requirement that the third party software also be free. As with the LGPL, any modifications made to the free software portions of a third party application, must also be made freely available.

[Note]

Note

The IcedTea build environment includes a very thorough, open source test suite titled JTreg. JTreg is intended to test the just built JDK for reasonable compatibility with the closed Oracle JDK. However, in order for an independent implementation to claim compatibility, including the Oracle sponsored OpenJDK project, it must pass a closed JCK/TCK test suite. No claims of compatibility, even partial compatibility, may be made without passing an approved test suite.

Oracle does provide free community access, on a case by case basis, to a closed toolkit to ensure 100% compatibility with its proprietary JDK. The binary version provided here has not been tested against the TCK. Any version that is built using the instructions given, cannot claim to be compatible with the proprietary JDK, without the user applying for, and completing the compatibility tests themselves.

With that in mind, the binaries produced using this build method are regularly tested against the TCK by the members listed on the site above. In addition to the community license above, an educational, non-commercial license for the TCK can be obtained from here.

Source Package Information

The following may be downladed separately or be done as a part of the make process.

Binary Package Information

Additional Downloads

Required Patches

Required JAR

OpenJDK Dependencies

Runtime Dependencies (required for binary installation)

Certificate Authority Certificates, Cups-1.6.2, GTK+-3.6.4, giflib-4.1.6, NSPR-4.9.6, PulseAudio-3.0 and Xorg Libraries

Additional Requirements (for source build, including runtime dependencies)

apache-ant-1.8.4, cpio-2.11, UnZip-6.0, Wget-1.14, which-2.20 and Zip-3.0

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/openjdk

Installation of OpenJDK

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.

OpenJDK Binary Installation

Begin by extracting the appropriate binary tarball and changing to the extracted directory. Install the binary OpenJDK with the following commands as the root user:

install -vdm755 /opt/OpenJDK-1.7.0.9-bin &&
mv -v * /opt/OpenJDK-1.7.0.9-bin         &&
chown -R root:root /opt/OpenJDK-1.7.0.9-bin

Configure the temporary OpenJDK installation with the following commands:

export CLASSPATH=.:/usr/share/java &&
export PATH="$PATH:/opt/OpenJDK-1.7.0.9-bin/bin

The binary version is now installed. If you don't want to compile the sources, skip ahead to the configuration section.

OpenJDK Source Installation

[Note]

Note

The source build of OpenJDK requires apache-ant-1.8.4. You'll need to build that first to satisfy the circular dependency, and return to this section to continue building OpenJDK.

Unlike other packages in BLFS, the OpenJDK source packages are distributed in multiple downloads. Since the IcedTea build harness will be used to build OpenJDK, begin by extracting the IcedTea package and changing into the extracted directory.

The IcedTea OpenJDK distribution requires that js.jar (from the Rhino package) be in place in order to provide a java-script implementation for the free JDK. If you have not installed the js.jar file in another way, do so with the following commands as the root user:

unzip ../rhino1_7R3.zip             &&
install -v -d -m755 /usr/share/java &&
install -v -m755 rhino1_7R3/*.jar /usr/share/java

As mentioned previously, OpenJDK is composed of several individual projects of the proprietary JDK that have been relicensed under an open source license. If you have already downoaded all of the individual components, place them into the source tree with the following commands:

cp -v ../corba.tar.gz     . &&
cp -v ../hotspot.tar.gz   . &&
cp -v ../jaxp.tar.gz      . &&
cp -v ../jaxws.tar.gz     . &&
cp -v ../jdk.tar.gz       . &&
cp -v ../langtools.tar.gz . &&
cp -v ../openjdk.tar.gz   .

Apply a patch to generate a valid cacerts file using the system CA certificates:

patch -Np1 -i ../icedtea-2.3.3-add_cacerts-1.patch

Apply a patch to replace fixed paths with ones appropriate for BLFS:

patch -Np1 -i ../icedtea-2.3.3-fixed_paths-1.patch

Apply a patch to exclude known broken tests from the test suite:

patch -Np1 -i ../icedtea-2.3.3-fix_tests-1.patch

Configure and build the package with the following commands:

unset JAVA_HOME &&
./autogen.sh &&
./configure --with-jdk-home=/opt/OpenJDK-1.7.0.9-bin \
            --enable-nss \
            --enable-pulse-java &&
make
[Note]

Note

If you have not installed the tarballs specified above, they will be automatically downloaded here.

To test the results, issue: make jtregcheck. The included version of jtreg is old, and the test suite is also very dependent on the host system and the environment that it is run in. You should expect to see anywhere between 40 and 100 failures in jdk with up to 10 errors in the tests themselves. The majority of the 6000+ tests should pass. The reason for the greatly varying results is due to how stringent the testing environment must be. Varying architectures, different versions of dependent libraries, unexpected X Window environment and window managers, the CA certificates used to generate the cacerts file, and even any user input or power management or screen saver interruptions during the testing can lead to various failures. While the known broken tests have been removed, with the fix_tests patch above, the graphics tests failures cannot be pre-determined (short of removing them all). The best bet for the minimal number of failures is to run the test suite in a framebuffer on a different screen (Xvfb). Even still, Disk I/O can cause failures.

Install the package with the following commands as the root user:

chmod 0644 openjdk.build/j2sdk-image/lib/sa-jdi.jar  &&
cp -R openjdk.build/j2sdk-image /opt/OpenJDK-1.7.0.9 &&
chown -R root:root /opt/OpenJDK-1.7.0.9

Command Explanations

./autogen.sh: This command forces rebuilding of auto-generated files to account for new options added to configure.

--with-jdk-home: This switch provides the location of the temporary JDK.

--enable-pulse-java: This switch enables building of the pulseaudio libraries (needed to provide a complete implementation that is reasonably compatible with the proprietary JDK).

chmod -v 0644 ...sa-jdi.jar: Fix permissions in a generated file so all users can access it.

Configuring OpenJDK

Configuration Information

There are now two OpenJDK 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 OpenJDK, do the following as the root user:

ln -v -nsf OpenJDK-1.7.0.9-bin /opt/jdk

The information below assumes your system is set up using the instructions found in “The Bash Shell Startup Files”. 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 openjdk.sh shell startup file to the /etc/profile.d directory with the following commands as the root user:

cat > /etc/profile.d/openjdk.sh << "EOF"
# Begin /etc/profile.d/openjdk.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/share/java

pathprepend . CLASSPATH

for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do
    pathappend $dir CLASSPATH
done

for jar in `find ${AUTO_CLASSPATH_DIR} -name "*.jar" 2>/dev/null`; do
    pathappend $jar CLASSPATH
done

export JAVA_HOME CLASSPATH
unset AUTO_CLASSPATH_DIR dir jar

# End /etc/profile.d/openjdk.sh
EOF

Finally, add the man pages to man_db's configuration. As the root user:

cat >> /etc/man_db.conf << "EOF" &&
MANDATORY_MANPATH     /opt/jdk/man
MANPATH_MAP           /opt/jdk/bin     /opt/jdk/man
MANDB_MAP             /opt/jdk/man     /var/cache/man/jdk
EOF
mandb -c /opt/OpenJDK/man

Contents

Installed Programs: appletviewer, apt, extcheck, idlj, jar, jarsigner, java, javac, javadoc, javah, javap, java-rmi.cgi, jcmd, 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
Installed Libraries: /opt/OpenJDK-1.7.0.9/lib/*, and /opt/OpenJDK-1.7.0.9/jre/lib/*
Installed Directory: /opt/OpenJDK-1.7.0.9

Short Descriptions

appletviewer

allows you to run applets outside of a web browser.

apt

is an annotation processing tool.

extcheck

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

idlj

generates Java bindings from a given IDL file.

jar

combines multiple files into a single jar archive.

jarsigner

signs jar files and verifies the signatures and integrity of a signed jar file.

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.

java-rmi.cgi

is the Java RMI client.

jcmd

is a utility to send diagnostic command requests to a running Java Virtual Machine.

jconsole

is a graphical console tool to monitor and manage both local and remote Java applications and virtual machines.

jdb

is a simple command-line debugger for Java classes.

jhat

parses a java heap dump file and allows viewing in a web browser.

jinfo

prints Java configuration information for a given Java process, core file, or a remote debug server.

jmap

prints shared object memory maps or heap memory details of a given process, core file, or a remote debug server.

jps

lists the instrumented JVMs on the target system.

jrunscript

is a command line script shell.

jsadebugd

attaches to a Java process or core file and acts as a debug server.

jstack

prints Java stack traces of Java threads for a given Java process, core file, or a remote debug server.

jstat

displays performance statistics for an instrumented JVM.

jstatd

is an RMI server application that monitors for the creation and termination of instrumented JVMs.

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.

pack200

is a Java application that transforms a jar file into a compressed pack200 file using the Java gzip compressor.

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.

schemagen

is a Java XML binding schema generator.

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.

unpack200

is a native implementation that transforms a packed file produced by pack200 into a jar file.

wsgen

generates JAX-WS portable artifacts used in JAX-WS web services.

wsimport

generates JAX-WS portable artifacts.

xjc

is a Java XML binding compiler.

Last updated on 2013-03-24 15:54:37 +0000