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