glfs/general/prog/jdk.xml

683 lines
26 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../../general.ent">
%general-entities;
<!ENTITY jdk-download-source "http://download.java.net/tiger/archive/tiger_u10/">
<!ENTITY jdk-download-binary "http://java.sun.com/j2se/1.5.0/download.jsp">
<!ENTITY jdk-source-md5sum "&sources-anduin-http;/j/jdk-&jdk-src-version;.md5sums">
<!ENTITY jdk-bin-md5sum "d916c24bed9eef7aebc2626115e14a11">
<!ENTITY jdk-bin-size "47.2 MB">
<!ENTITY jdk-src-size "64.2 MB (three .jar files)">
<!ENTITY jdk-src-buildsize "1882 MB">
<!ENTITY jdk-time "34 SBU">
]>
<sect1 id="jdk" xreflabel="JDK-&jdk-src-version;">
<?dbhtml filename="jdk.html" ?>
<sect1info>
<othername>$LastChangedBy$</othername>
<date>$Date$</date>
</sect1info>
<title>JDK-&jdk-src-version;</title>
<indexterm zone="jdk">
<primary sortas="a-JDK">JDK</primary>
</indexterm>
<sect2 role="package">
<title>Introduction to JDK</title>
<para>The <application>JDK</application> package contains
Sun's <application>Java</application> development environment. This is
useful for developing <application>Java</application> programs and provides
the runtime environment necessary to run <application>Java</application>
programs. It also includes a plug-in for browsers so that they can be
<application>Java</application> aware.</para>
<para>The <application>JDK</application> comes in two flavors, a
precompiled binary and a source package. Previously, the plugin included
in the <application>JDK</application> binary package was unusable on LFS
owing to incompatibilities with <application>GCC</application>-3 compiled
browsers. This is not the case anymore.</para>
<para>In order to use the source code and patches, you must read and agree
to the Sun <ulink url="http://www.java.net/jrl.csp"> Java Research
License</ulink> or optionally, the Sun <ulink
url="http://java.net/jiul.csp">Java Internal Use License</ulink>. 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.</para>
<para>You will first need to download and install the binary version of the
<application>JDK</application>.</para>
<para>To build from the source, you will also need to download the
additional files and patches to complete the source build as detailed
below.</para>
<bridgehead renderas="sect3">Package Information</bridgehead>
<itemizedlist spacing="compact">
<listitem>
<para>Binary download: <ulink url="&jdk-download-binary;"/>
(to download jdk-&jdk-bin-string;-linux-i586.bin)</para>
</listitem>
<listitem>
<para>Download MD5 sum (binary): &jdk-bin-md5sum;</para>
</listitem>
<listitem>
<para>Source download: <ulink url="&jdk-download-source;"/>
(to download jdk-&jdk-src-string;-fcs-src-b03-jrl-09_nov_2006.jar (or
optionally the JIUL version),
jdk-&jdk-src-string;-fcs-bin-b03-09_nov_2006.jar, and
jdk-&jdk-src-string;-mozilla_headers-b03-unix-09_nov_2006.jar)</para>
</listitem>
<listitem>
<para>Download MD5 sums (source):
<simplelist>
<member>09842a4e68040db473e04dbcc284f1d5
jdk-&jdk-src-string;-fcs-bin-b03-09_nov_2006.jar
</member>
<member>b59335f620e7da524be168b07319fa3b
jdk-&jdk-src-string;-fcs-src-b03-jrl-09_nov_2006.jar
</member>
<member>f49df1a1e7fe351b7fa9f66db121616e
jdk-&jdk-src-string;-mozilla_headers-b03-unix-09_nov_2006.jar
</member>
</simplelist>
</para>
</listitem>
<listitem>
<para>Download size (binary): &jdk-bin-size;</para>
</listitem>
<listitem>
<para>Download size (source): &jdk-src-size;</para>
</listitem>
<listitem>
<para>Estimated disk space required: &jdk-src-buildsize;</para>
</listitem>
<listitem>
<para>Estimated build time: &jdk-time;</para>
</listitem>
</itemizedlist>
<bridgehead renderas="sect3">Additional Downloads</bridgehead>
<bridgehead renderas="sect4">Required Patches</bridgehead>
<itemizedlist spacing='compact'>
<listitem>
<para><ulink
url="&patch-root;/jdk-&jdk-src-version;-gcc4-1.patch"/></para>
</listitem>
<listitem>
<para><ulink
url="&patch-root;/jdk-&jdk-src-version;-motif_fixes-1.patch"/></para>
</listitem>
<listitem>
<para><ulink
url="&patch-root;/jdk-&jdk-src-version;-nptl-1.patch"/></para></listitem>
<listitem>
<para><ulink
url="&patch-root;/jdk-&jdk-src-version;-remove_broken_demo-1.patch"/></para>
</listitem>
<listitem>
<para><ulink
url="&patch-root;/jdk-&jdk-src-version;-remove_fixed_paths-1.patch"/></para>
</listitem>
</itemizedlist>
<bridgehead renderas="sect4">Recommended Patches</bridgehead>
<itemizedlist spacing='compact'>
<listitem>
<para><ulink
url="&patch-root;/jdk-&jdk-src-version;-remove_debug_image-1.patch"/>
(skips compiling of the <application>JDK</application> debug image)</para>
</listitem>
<listitem>
<para><ulink
url="&patch-root;/jdk-&jdk-src-version;-static_cxx-1.patch"/>
(forces dynamic linking to <application>GCC</application> libs)</para></listitem>
</itemizedlist>
<bridgehead renderas="sect3">JDK Dependencies</bridgehead>
<bridgehead renderas="sect4">Required (to Build JDK from Source)</bridgehead>
<para role="required"><xref linkend="x-window-system"/>,
<xref linkend="zip"/>,
<xref linkend="unzip"/>,
<xref linkend="cpio"/>,
<xref linkend="alsa-lib"/>, and
<xref linkend="tcsh"/></para>
<para condition="html" role="usernotes">User Notes:
<ulink url="&blfs-wiki;/jdk"/></para>
</sect2>
<sect2 role="installation">
<title>Installation of JDK</title>
<para>Both the binary and source built versions will be installed. You may
choose to keep either or both.</para>
<tip>
<para>The <command>./jdk-mod.bin</command>
command below unpacks the distribution into a
<filename class='directory'>jdk&jdk-bin-version;</filename> directory.
You will be required to view, and then accept (by entering a
<keycap>y</keycap> 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 <xref linkend="automating-builds"/> section of Chapter 2. Towards
the end of this section, specific information for automating this type of
installation is discussed.</para>
</tip>
<para>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.</para>
<para>Install the precompiled <application>JDK</application> with the
following commands:</para>
<screen><userinput>cp jdk-&jdk-bin-string;-linux-i?86.bin jdk-mod.bin &amp;&amp;
sed -i "s:^PATH=.*::" jdk-mod.bin &amp;&amp;
chmod -v +x jdk-mod.bin &amp;&amp;
./jdk-mod.bin</userinput></screen>
<para>Now, as the <systemitem class="username">root</systemitem> user:</para>
<screen role="root"><userinput>cd jdk&jdk-bin-version; &amp;&amp;
install -v -d /opt/jdk/jdk-precompiled-&jdk-bin-version; &amp;&amp;
mv -v * /opt/jdk/jdk-precompiled-&jdk-bin-version; &amp;&amp;
chown -v -R root:root /opt/jdk/jdk-precompiled-&jdk-bin-version; &amp;&amp;
ln -v -sf motif21/libmawt.so \
/opt/jdk/jdk-precompiled-&jdk-bin-version;/jre/lib/i386/ &amp;&amp;
cd ..</userinput></screen>
<para>The binary version is now installed.</para>
<para>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.</para>
<para>Save the existing path, and append the recently installed
<application>JDK</application>.</para>
<screen><userinput>export JAVA_HOME=/opt/jdk/jdk-precompiled-&jdk-bin-version; &amp;&amp;
export PATH_HOLD=${PATH} &amp;&amp;
export PATH=${PATH}:${JAVA_HOME}/bin</userinput></screen>
<para>The source code is contained in self-extracting
<filename class='extension'>jar</filename> 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 <filename class="directory">jdk-build</filename> directory
when prompted for the target directory.</para>
<screen><userinput>mkdir jdk-build &amp;&amp;
cd jdk-build &amp;&amp;
for JAR in ../jdk-&jdk-src-string;*.jar
do java -jar ${JAR}
done</userinput></screen>
<para>Apply all the patches downloaded above:</para>
<screen><userinput>for PATCH in ../jdk-&jdk-src-version;*.patch
do patch -Np1 -i ${PATCH}
done</userinput></screen>
<para>If your <application>X Window System</application> is installed into
any prefix other than <filename class="directory">/usr/X11R6</filename>,
execute the following command, replacing
<replaceable>&lt;PREFIX&gt;</replaceable> with the installation prefix of
the <application>X Window System</application>:</para>
<screen><userinput>find . -type f -exec sed -i 's@/usr/X11R6@<replaceable>&lt;PREFIX&gt;</replaceable>@g' {} \;</userinput></screen>
<para>Set/unset some variables which affect the build:</para>
<screen><userinput>export ALT_BOOTDIR=${JAVA_HOME} &amp;&amp;
export CLASSPATH_HOLD=${CLASSPATH} &amp;&amp;
unset JAVA_HOME CLASSPATH CFLAGS CXXFLAGS LDFLAGS &amp;&amp;
export ALT_DEVTOOLS_PATH="/usr/bin" &amp;&amp;
export BUILD_NUMBER="update-10" &amp;&amp;
export DEV_ONLY=true &amp;&amp;
export ALT_MOZILLA_HEADERS_PATH=${PWD}/share/plugin/ &amp;&amp;
export INSANE=true &amp;&amp;
export MAKE_VERBOSE=true &amp;&amp;
export ALT_CACERTS_FILE=${ALT_BOOTDIR}/jre/lib/security/cacerts</userinput></screen>
<warning>
<para>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.</para>
</warning>
<para>Additionally, if you would like to <command>make</command> in
parallel, add the following:</para>
<screen><userinput>export HOTSPOT_BUILD_JOBS=<replaceable>&lt;3&gt;</replaceable></userinput></screen>
<para>Build the <application>JDK</application> with the following
commands. There will be a lot of 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.</para>
<screen><userinput>cd control/make &amp;&amp;
make &amp;&amp;
cd ../build/linux-i?86</userinput></screen>
<para>To test the results, you can run one of the provided demo programs
using the newly created <command>java</command> binary. Issue the
following commands:</para>
<screen><userinput>cd j2sdk-image/demo/jfc/Java2D &amp;&amp;
../../../bin/java -jar Java2Demo.jar &amp;&amp;
cd ../../../..</userinput></screen>
<para>Now, as the <systemitem class="username">root</systemitem> user,
install the <application>JDK</application>:</para>
<screen role="root"><userinput>cp -v -a j2sdk-image /opt/jdk/jdk-&jdk-src-version; &amp;&amp;
chown -v -R root:root /opt/jdk/jdk-&jdk-src-version; &amp;&amp;
ln -v -sf motif21/libmawt.so /opt/jdk/jdk-&jdk-src-version;/jre/lib/i386/</userinput></screen>
<para>Restore the unprivileged user's environment using the following
commands:</para>
<screen><userinput>export JAVA_HOME=${ALT_BOOTDIR} &amp;&amp;
export CLASSPATH=${CLASSPATH_HOLD} &amp;&amp;
export PATH=${PATH_HOLD} &amp;&amp;
unset ALT_BOOTDIR CLASSPATH_HOLD ALT_DEVTOOLS_PATH BUILD_NUMBER &amp;&amp;
unset DEV_ONLY ALT_MOZILLA_HEADERS_PATH INSANE MAKE_VERBOSE &amp;&amp;
unset ALT_CACERTS_FILE PATH_HOLD</userinput></screen>
</sect2>
<sect2 role="commands">
<title>Command Explanations</title>
<para><command>export ALT_BOOTDIR=${JAVA_HOME}</command>: This variable sets
the location of the bootstrap <application>JDK</application>.</para>
<para><command>export ALT_MOZILLA_HEADERS_PATH=${PWD}/share/plugin/</command>:
This tells the build exactly where to find the
<application>Mozilla</application> headers. This has changed since the
previous version and is not mentioned in the installation documentation
included with the package source.</para>
<para><command>export ALT_DEVTOOLS_PATH="/usr/bin"</command>: This
changes the location where the build finds the needed executables.</para>
<para><command>export BUILD_NUMBER="update-10"</command>:
This will help you identify the compiled version of the runtime environment
and virtual machine by appending this information to the version
string.</para>
<para><command>export DEV_ONLY=true</command>: This command
skips compiling the documentation and eliminates a dependency on
<application>rpm</application>.</para>
<para><command>unset JAVA_HOME CLASSPATH CFLAGS CXXFLAGS LDFLAGS</command>:
These variables cause miscompilation of the build. Never set them.</para>
<para><command>export INSANE=true</command>: 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.</para>
<para><command>export MAKE_VERBOSE=true</command>: Allows the compiler
commands to be displayed on the console.</para>
<para><command>export ALT_CACERTS_FILE...</command>: Specifies the
certificate file to use (from the installed binary
<application>JDK</application>).</para>
<para><command>ln -sf motif21/libmawt.so
/opt/jdk/jdk-&jdk-src-version;/jre/lib/i386/</command>: This fixes
linking issues with other applications that expect to find the
<application>motif</application> libraries with the other
<application>JDK</application> libraries.</para>
</sect2>
<sect2 role="configuration">
<title>Configuring JDK</title>
<sect3>
<title>Configuration Information</title>
<para>There are now two Java 2 SDKs installed in
<filename>/opt/jdk</filename>. You should decide on which one you
would like to use as the default. For example if you decide to use the
source compiled <application>JDK</application>, do the following as the
<systemitem class="username">root</systemitem> user:</para>
<screen role="root"><userinput>ln -v -nsf jdk-&jdk-src-version; /opt/jdk/jdk</userinput></screen>
<para>Add the following <filename>jdk.sh</filename> shell startup file to
the <filename>/etc/profile.d</filename> directory with the following
commands as the <systemitem class="username">root</systemitem> user:</para>
<screen role="root"><userinput>cat &gt; /etc/profile.d/jdk.sh &lt;&lt; "EOF"
<literal># Begin /etc/profile.d/jdk.sh
# Set JAVA_HOME directory
JAVA_HOME=/opt/jdk/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</literal>
EOF</userinput></screen>
<para>The <application>Java</application> plugin is located in
<filename class="directory">$JAVA_HOME/jre/plugin/i?86/ns7/</filename>.
Make a symbolic link to the file in that directory from your browser(s)
plugins directory.</para>
<important>
<para>The plugin must be a symlink for it to work. If not, the browsers
will crash when you attempt to load a <application>Java</application>
application.</para>
</important>
</sect3>
</sect2>
<sect2 role="content">
<title>Contents</title>
<segmentedlist>
<segtitle>Installed Programs</segtitle>
<segtitle>Installed Libraries</segtitle>
<segtitle>Installed Directory</segtitle>
<seglistitem>
<seg>appletviewer, extcheck, idlj, jar, jarsigner, java, javac,
javadoc,javah, javap, javaws, jdb, keytool, native2ascii, orbd,
policytool, rmic, rmid, rmiregistry, serialver, servertool, and
tnameserv</seg>
<seg><envar>$JAVA_HOME</envar>/lib/*,
<envar>$JAVA_HOME</envar>/jre/lib/*,
and libjavaplugin_oji.so</seg>
<seg>/opt/jdk</seg>
</seglistitem>
</segmentedlist>
<variablelist>
<bridgehead renderas="sect3">Short Descriptions</bridgehead>
<?dbfo list-presentation="list"?>
<?dbhtml list-presentation="table"?>
<varlistentry id="appletviewer">
<term><command>appletviewer</command></term>
<listitem>
<para>runs <application>Java</application> applets outside of the
context of a browser.</para>
<indexterm zone="jdk appletviewer">
<primary sortas="b-appletviewer">appletviewer</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="extcheck">
<term><command>extcheck</command></term>
<listitem>
<para>checks a specified <filename>JAR</filename> file for title
and version conflicts with any extensions installed in the
<application>JDK</application> software.</para>
<indexterm zone="jdk extcheck">
<primary sortas="b-extcheck">extcheck</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="idlj">
<term><command>idlj</command></term>
<listitem>
<para>generates <application>Java</application> bindings from a
given IDL file.</para>
<indexterm zone="jdk idlj">
<primary sortas="b-idlj">idlj</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="jar">
<term><command>jar</command></term>
<listitem>
<para>combines multiple files into a single <filename>JAR</filename>
archive file.</para>
<indexterm zone="jdk jar">
<primary sortas="b-jar">jar</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="jarsigner">
<term><command>jarsigner</command></term>
<listitem>
<para>signs <filename>JAR</filename> (Java ARchive) files and verifies the
signatures and integrity of a signed <filename>JAR</filename>.</para>
<indexterm zone="jdk jarsigner">
<primary sortas="b-jarsigner">jarsigner</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="java">
<term><command>java</command></term>
<listitem>
<para>launches a <application>Java</application> application by
starting a <application>Java</application> runtime environment, loading a
specified class and invoking its main method.</para>
<indexterm zone="jdk java">
<primary sortas="b-java">java</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="javac">
<term><command>javac</command></term>
<listitem>
<para>reads class and interface definitions, written in the
<application>Java</application> programming language, and compiles
them into bytecode class files.</para>
<indexterm zone="jdk javac">
<primary sortas="b-javac">javac</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="javadoc">
<term><command>javadoc</command></term>
<listitem>
<para>parses the declarations and documentation comments in a set of
<application>Java</application> source files and produces a corresponding
set of HTML pages describing the classes, interfaces,
constructors, methods, and fields.</para>
<indexterm zone="jdk javadoc">
<primary sortas="b-javadoc">javadoc</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="javah">
<term><command>javah</command></term>
<listitem>
<para>generates <application>C</application> header and source files
that are needed to implement native methods.</para>
<indexterm zone="jdk javah">
<primary sortas="b-javah">javah</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="javap">
<term><command>javap</command></term>
<listitem>
<para>disassembles a <application>Java</application> class file.</para>
<indexterm zone="jdk javap">
<primary sortas="b-javap">javap</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="javaws">
<term><command>javaws</command></term>
<listitem>
<para>launches <application>Java </application>application/applets
hosted on a network.</para>
<indexterm zone="jdk javaws">
<primary sortas="b-javaws">javaws</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="jdb">
<term><command>jdb</command></term>
<listitem>
<para>is a simple command-line debugger for
<application>Java</application> classes.</para>
<indexterm zone="jdk jdb">
<primary sortas="b-jdb">jdb</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="keytool">
<term><command>keytool</command></term>
<listitem>
<para>is a key and certificate management utility.</para>
<indexterm zone="jdk keytool">
<primary sortas="b-keytool">keytool</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="native2ascii">
<term><command>native2ascii</command></term>
<listitem>
<para> converts files that contain non-supported character encoding
into files containing Latin-1 or Unicode-encoded characters.</para>
<indexterm zone="jdk native2ascii">
<primary sortas="b-native2ascii">native2ascii</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="orbd">
<term><command>orbd</command></term>
<listitem>
<para>is used to enable clients to transparently locate and invoke
persistent objects on servers in the CORBA environment.</para>
<indexterm zone="jdk orbd">
<primary sortas="b-orbd">orbd</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="policytool">
<term><command>policytool</command></term>
<listitem>
<para>creates and manages a policy file graphically.</para>
<indexterm zone="jdk policytool">
<primary sortas="b-policytool">policytool</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="rmic">
<term><command>rmic</command></term>
<listitem>
<para>generates stub and skeleton class files for remote objects
from the names of compiled <application>Java</application> classes that
contain remote object implementations.</para>
<indexterm zone="jdk rmic">
<primary sortas="b-rmic">rmic</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="rmid">
<term><command>rmid</command></term>
<listitem>
<para>starts the activation system daemon.</para>
<indexterm zone="jdk rmid">
<primary sortas="b-rmid">rmid</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="rmiregistry">
<term><command>rmiregistry</command></term>
<listitem>
<para>creates and starts a remote object registry on the specified
port on the current host.</para>
<indexterm zone="jdk rmiregistry">
<primary sortas="b-rmiregistry">rmiregistry</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="serialver">
<term><command>serialver</command></term>
<listitem>
<para>returns the serialVersionUID for one or more classes in a
form suitable for copying into an evolving class.</para>
<indexterm zone="jdk serialver">
<primary sortas="b-serialver">serialver</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="servertool">
<term><command>servertool</command></term>
<listitem>
<para>provides an ease-of-use interface for application programmers
to register, unregister, startup and shutdown a server.</para>
<indexterm zone="jdk servertool">
<primary sortas="b-servertool">servertool</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="tnameserv">
<term><command>tnameserv</command></term>
<listitem>
<para>starts the <application>Java</application> IDL name server.</para>
<indexterm zone="jdk tnameserv">
<primary sortas="b-tnameserv">tnameserv</primary>
</indexterm>
</listitem>
</varlistentry>
</variablelist>
</sect2>
</sect1>