[784a1a7f] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 |
|
---|
| 7 | <!ENTITY anduin-download "http://anduin.linuxfromscratch.org/files/BLFS/OpenJDK-&openjdk-version;">
|
---|
| 8 | <!ENTITY openjdk-download-binary-x86 "&anduin-download;/OpenJDK-&openjdk-version;-i686-bin.tar.xz">
|
---|
[c936adc6] | 9 | <!ENTITY openjdk-bin-md5sum-x86 "16ae4a3518def3943496006a755cd4a2">
|
---|
| 10 | <!ENTITY openjdk-bin-size-x86 "174 MB">
|
---|
| 11 | <!ENTITY openjdk-bin-buildsize-x86 "547 MB">
|
---|
[784a1a7f] | 12 |
|
---|
| 13 | <!ENTITY openjdk-download-binary-x64 "&anduin-download;/OpenJDK-&openjdk-version;-x86_64-bin.tar.xz">
|
---|
[c936adc6] | 14 | <!ENTITY openjdk-bin-md5sum-x64 "d40a5a3b9f16ce8fd2fddc8866c9be00">
|
---|
| 15 | <!ENTITY openjdk-bin-size-x64 "218 MB">
|
---|
| 16 | <!ENTITY openjdk-bin-buildsize-x64 "424 MB">
|
---|
[784a1a7f] | 17 | ]>
|
---|
| 18 |
|
---|
| 19 | <sect1 id="java">
|
---|
| 20 | <?dbhtml filename="java.html"?>
|
---|
| 21 |
|
---|
| 22 | <sect1info>
|
---|
| 23 | <othername>$LastChangedBy$</othername>
|
---|
| 24 | <date>$Date$</date>
|
---|
| 25 | </sect1info>
|
---|
| 26 |
|
---|
| 27 | <title>About Java</title>
|
---|
| 28 |
|
---|
| 29 | <indexterm zone="java">
|
---|
| 30 | <primary sortas="a-java">JDK Binary</primary>
|
---|
| 31 | </indexterm>
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | <para>Java is different from most of the packages in LFS and BLFS. It
|
---|
| 35 | is a programming language that works with files of byte codes to obtain
|
---|
| 36 | instructions and executes then in a Java Virtual Machine (JVM). An
|
---|
| 37 | introductory java program looks like:</para>
|
---|
| 38 |
|
---|
| 39 | <screen><literal>public class HelloWorld
|
---|
| 40 | {
|
---|
| 41 | public static void main(String[] args)
|
---|
| 42 | {
|
---|
| 43 | System.out.println("Hello, World");
|
---|
| 44 | }
|
---|
| 45 | }</literal></screen>
|
---|
| 46 |
|
---|
| 47 | <para>This program is saved as <filename>HelloWorld.java</filename>. The file
|
---|
| 48 | name, <emphasis>HelloWorld</emphasis>, must match the class name. It
|
---|
| 49 | is then converted into byte code with <command>javac HelloWorld.java</command>.
|
---|
| 50 | The output file is <filename>HelloWorld.class</filename>. The program is
|
---|
| 51 | executed with <command>java HelloWorld</command>. This creates a JVM and
|
---|
[c4b0455] | 52 | runs the code. The 'class' extension must not be specified.</para>
|
---|
[784a1a7f] | 53 |
|
---|
| 54 | <para>Several class files can be combined into one file with the
|
---|
| 55 | <command>jar</command> command. This is similar to the standard
|
---|
| 56 | <command>tar</command> command. For instance, the command <command>jar cf myjar.jar
|
---|
| 57 | *.class</command> will combine all class files in a directory into one jar
|
---|
| 58 | file. These act as library files.</para>
|
---|
| 59 |
|
---|
| 60 | <para>The JVM can search for and use classes in jar files automatically. It
|
---|
[debb88bf] | 61 | uses the <envar>CLASSPATH</envar> environment variable to search for jar files.
|
---|
| 62 | This is a standard list of colon-separated directory names similar to
|
---|
| 63 | the <envar>PATH</envar> environment variable.</para>
|
---|
[784a1a7f] | 64 |
|
---|
[e1e9a2a] | 65 | &lfs74_checked;
|
---|
[784a1a7f] | 66 |
|
---|
[debb88bf] | 67 | <sect2 id="java-bin" xreflabel="Java Binary">
|
---|
[784a1a7f] | 68 | <title>Installing a binary JDK</title>
|
---|
| 69 |
|
---|
| 70 | <para>Creating a JVM from source requires a set of circular dependencies.
|
---|
| 71 | The first thing that's needed is a set of programs called a Java Development
|
---|
| 72 | Kit (JDK). This set of programs includes <command>java</command>,
|
---|
| 73 | <command>javac</command>, <command>jar</command>, and severl others. It
|
---|
| 74 | also includes several base <emphasis>jar</emphasis> files.</para>
|
---|
| 75 |
|
---|
| 76 | <para>To start, we set up a binary installation of the JDK created
|
---|
| 77 | by the BLFS editors. It is installed in the <filename>/opt</filename>
|
---|
| 78 | directory to allow for multiple installations, including a source based
|
---|
| 79 | version.</para>
|
---|
| 80 |
|
---|
| 81 | <bridgehead renderas="sect3">Binary Package Information</bridgehead>
|
---|
| 82 | <itemizedlist spacing="compact">
|
---|
| 83 | <listitem>
|
---|
| 84 | <para>Binary download (x86):
|
---|
| 85 | <ulink url="&openjdk-download-binary-x86;"/></para>
|
---|
| 86 | </listitem>
|
---|
| 87 | <listitem>
|
---|
| 88 | <para>Download MD5 sum: &openjdk-bin-md5sum-x86;</para>
|
---|
| 89 | </listitem>
|
---|
| 90 | <listitem>
|
---|
| 91 | <para>Download size (binary): &openjdk-bin-size-x86;</para>
|
---|
| 92 | </listitem>
|
---|
| 93 | <listitem>
|
---|
| 94 | <para>Estimated disk space required: &openjdk-bin-buildsize-x86;</para>
|
---|
| 95 | </listitem>
|
---|
| 96 | </itemizedlist>
|
---|
| 97 | <itemizedlist spacing="compact">
|
---|
| 98 | <listitem>
|
---|
| 99 | <para>Binary download (x86_64):
|
---|
| 100 | <ulink url="&openjdk-download-binary-x64;"/></para>
|
---|
| 101 | </listitem>
|
---|
| 102 | <listitem>
|
---|
| 103 | <para>Download MD5 sum: &openjdk-bin-md5sum-x64;</para>
|
---|
| 104 | </listitem>
|
---|
| 105 | <listitem>
|
---|
| 106 | <para>Download size (binary): &openjdk-bin-size-x64;</para>
|
---|
| 107 | </listitem>
|
---|
| 108 | <listitem>
|
---|
| 109 | <para>Estimated disk space required: &openjdk-bin-buildsize-x64;</para>
|
---|
| 110 | </listitem>
|
---|
| 111 | </itemizedlist>
|
---|
| 112 |
|
---|
| 113 | <para>Begin by extracting the appropriate binary tarball for your
|
---|
[debb88bf] | 114 | architecture and changing to the extracted directory. Install the binary
|
---|
[784a1a7f] | 115 | <application>OpenJDK</application> with the following commands as the
|
---|
| 116 | <systemitem class="username">root</systemitem> user:</para>
|
---|
| 117 |
|
---|
| 118 | <screen role="root"><userinput>install -vdm755 /opt/OpenJDK-&openjdk-version;-bin &&
|
---|
| 119 | mv -v * /opt/OpenJDK-&openjdk-version;-bin &&
|
---|
| 120 | chown -R root:root /opt/OpenJDK-&openjdk-version;-bin</userinput></screen>
|
---|
| 121 |
|
---|
| 122 | <para>Configure the temporary <application>OpenJDK</application>
|
---|
| 123 | installation with the following commands:</para>
|
---|
| 124 |
|
---|
| 125 | <screen><userinput>export CLASSPATH=.:/usr/share/java &&
|
---|
| 126 | export PATH="$PATH:/opt/OpenJDK-&openjdk-version;-bin/bin"</userinput></screen>
|
---|
| 127 |
|
---|
| 128 | <para>The binary version is now installed. If you don't want to compile the
|
---|
| 129 | sources, skip ahead to the <xref linkend='openjdk-config'/> section.
|
---|
| 130 | Otherwise, continue to the <xref linkend='junit'/>, <xref
|
---|
| 131 | linkend='apache-ant'/>, and <xref linkend='openjdk'/> sections.</para>
|
---|
| 132 |
|
---|
| 133 | </sect2>
|
---|
| 134 |
|
---|
| 135 | </sect1>
|
---|