/[gentoo]/xml/htdocs/doc/en/java.xml
Gentoo

Diff of /xml/htdocs/doc/en/java.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.12 Revision 1.13
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/java.xml,v 1.12 2003/11/22 10:01:56 neysx Exp $ --> 2<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/java.xml,v 1.13 2005/02/07 19:27:44 swift Exp $ -->
3<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> 3<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
4 4
5<guide link="/doc/en/java.xml"> 5<guide link="/doc/en/java.xml">
6<title>Gentoo Java Guide</title> 6<title>Gentoo Java Guide</title>
7 7
8<author title="Author and Editor"> 8<author title="Author and Editor">
9 <mail link="karltk@gentoo.org">Karl Trygve Kalleberg</mail> 9 <mail link="karltk@gentoo.org">Karl Trygve Kalleberg</mail>
10</author> 10</author>
11<author title="Editor"> 11<author title="Editor">
12 <mail link="swift@gentoo.org">Sven Vermeulen</mail> 12 <mail link="swift@gentoo.org">Sven Vermeulen</mail>
13</author> 13</author>
14<author title="Editor">
15 <mail link="marcelogoes@gmail.com">Marcelo Góes</mail>
16</author>
14 17
15<abstract> 18<abstract>
16Users' and Developers' Guide to Java in Gentoo 19This guide will introduce users and developers to Java and explain how to use
20Java with Gentoo Linux.
17</abstract> 21</abstract>
18 22
19<license/> 23<license/>
20 24
21<version>0.1.4</version> 25<version>0.1.5</version>
22<date>November 21, 2003</date> 26<date>2005-02-07</date>
23 27
24<chapter> 28<chapter>
25<title>Installing a JDK/JRE</title> 29<title>What is Java?</title>
26<section> 30<section>
27<title>Overview</title> 31<title>Overview</title>
28<body> 32<body>
29 33
30<p> 34<p>
31Gentoo provides numerous JDKs and JREs. The default is the Blackdown JDK/JRE 35Java is a programming language developed by engineers of Sun Microsystems.
36The language is object-oriented and designed to run on multiple platforms
37without the need of recompiling code for each platform. Although Java can
38be compiled as a native program, much of Java's popularity can be attributed
39to its portability, along with other features such as garbage collection.
40The ability to compile once and run in various platforms is achieved through
41the use of just-in-time compilers (JIT), which compile Java bytecodes into
42native code when a given program is run.
43</p>
44
45<p>
46In order to run Java bytecodes, one needs to have a JRE (Java Runtime Environment)
47installed. A JRE provides core libraries, a platform dependent Java Virtual Machine,
48plug-ins for browsers, among other things. A JDK (Java Development Kit) adds
49programming tools, such as a bytecode compiler and a debugger.
50</p>
51
52</body>
53</section>
54</chapter>
55
56<chapter>
57<title>Installing a JRE/JDK</title>
58<section>
59<title>The choices</title>
60<body>
61
62<p>
63Gentoo provides numerous JREs and JDKs. Among the current alternatives, we have:
64</p>
65
66<ul>
67<li>blackdown-jre and blackdown-jdk, the Blackdown Java Kit</li>
68<li>sun-jre-bin and sun-jdk, Sun's Java Kit </li>
69<li>ibm-jre-bin and ibm-jdk-bin, the IBM Java Kit</li>
70<li>compaq-jre and compaq-jdk, the Compaq Java Kit for Alpha/Linux/GNU</li>
71<li>jrockit-jdk-bin, BEA WebLogic's J2SE Development Kit</li>
72</ul>
73
74<p>
75The default is the Blackdown JRE/JDK
32pair, as it is freely (beer) available without any registration fuss. 76pair, as it is freely (beer) available without any registration fuss.
33</p> 77</p>
34 78
35<note>
36As kaffe becomes a JRE/JDK drop-in replacement, that will most likely become our
37default.
38</note>
39
40<p> 79<p>
41Both the Sun JDK/JRE and the IBM JDK/JRE are generally faster, but getting them 80Both the Sun JRE/JDK and the IBM JRE/JDK are generally faster, but getting them
42is a bit more work, as you are required to read and accept their license before 81is a bit more work, as you are required to read and accept their license before
43downloading (IBM additionally requires you to register). 82downloading (IBM additionally requires you to register).
44</p> 83</p>
45 84
46<p> 85<p>
47Our ebuilds for the Sun and IBM JDK/JREs will notify you of where to go to 86Our ebuilds for the Sun and IBM JRE/JDKs will notify you of where to go to
48download them. 87download them.
49</p> 88</p>
50 89
51</body> 90</body>
52</section> 91</section>
53 92
54<section> 93<section>
55<title>Installing the Sun/IBM JDK/JREs</title> 94<title>Installing the Sun/IBM JRE/JDKs</title>
56<body> 95<body>
57 96
58<p> 97<p>
59If you run <c>emerge sun-jdk-1.3.1</c> or <c>emerge ibm-jdk-1.3.1</c>, you will 98If you run <c>emerge =sun-jdk-1.4.2.06</c> or <c>=ibm-jdk-bin-1.4.2</c>, you will
60be notified that you are required to download the actual tarballs yourself. This 99be notified that you are required to download the actual tarballs yourself. This
61has to do with license restrictions for the Sun JDK/JRE (online click-wrap 100has to do with license restrictions for the Sun JRE/JDK (online click-wrap
62license) and registration issues with the IBM JDK/JRE. 101license) and registration issues with the IBM JRE/JDK.
63</p> 102</p>
64 103
65<note> 104<note>
66There is also a sun-jdk-1.4.0, but not all packages work nicely with Java 1.4, 105ibm-jdk-bin is currently masked, you may have to unmask it to use it.
67so you're on your own if you use the 1.4.0 JDK.
68</note> 106</note>
69 107
70<p> 108<p>
71You should download the indicated file(s) into 109You should download the indicated file(s) into
72<path>/usr/portage/distfiles</path>. Once that is done, you can rerun the emerge 110<path>/usr/portage/distfiles</path>. Once that is done, you can rerun the emerge
73command, then the JDK/JRE will be installed properly into <path>/opt</path>. 111command, then the JRE/JDK will be installed properly into <path>/opt</path>.
74</p> 112</p>
75 113
76</body> 114</body>
77</section> 115</section>
78</chapter>
79
80<chapter> 116</chapter>
117
118<chapter>
81<title>Configuring your JDK/JRE</title> 119<title>Configuring your JRE/JDK</title>
82<section> 120<section>
83<title>Overview</title> 121<title>Overview</title>
84<body> 122<body>
85 123
86<p> 124<p>
87Gentoo has the ability to have multiple JDKs and JREs installed without them 125Gentoo has the ability to have multiple JDKs and JREs installed without them
88conflicting. 126conflicting.
89</p> 127</p>
90 128
91<p> 129<p>
92Using the <c>java-config</c> tool, you can set the system-wide default if you 130Using the <c>java-config</c> tool, you can set the system-wide default if you
93have root access. Users can also use <c>java-config</c> to set up their own 131have root access. Users can also use <c>java-config</c> to set up their own
94personal default, that is different from the system-wide default. 132personal default, that is different from the system-wide default.
95</p> 133</p>
96 134
97</body> 135</body>
98</section> 136</section>
99 137
100<section> 138<section>
101<title>Setting a default JDK/JRE</title> 139<title>Setting a default JRE/JDK</title>
102<body> 140<body>
103 141
104<p> 142<p>
105Running the command <c>java-config --list-available-vms</c> will give you a list 143Running the command <c>java-config --list-available-vms</c> will give you a list
106of all available JREs and JDKs on your system, thus: 144of all available JREs and JDKs on your system. Here is an example of output:
107</p> 145</p>
108 146
109<pre caption="Listing available VMs"> 147<pre caption="Listing available VMs">
110# <i>java-config --list-available-vms</i> 148# <i>java-config --list-available-vms</i>
111[blackdown-jdk-1.3.1] Blackdown JDK 1.3.1 (/etc/env.d/java/20blackdown-jdk-1.3.1) 149[blackdown-jdk-1.3.1] Blackdown JDK 1.3.1 (/etc/env.d/java/20blackdown-jdk-1.3.1)
112[blackdown-jre-1.3.1] Blackdown JRE 1.3.1 (/etc/env.d/java/20blackdown-jre-1.3.1) 150[blackdown-jre-1.3.1] Blackdown JRE 1.3.1 (/etc/env.d/java/20blackdown-jre-1.3.1)
113[ibm-jdk-1.3.0] IBM JDK 1.3.0 (/etc/env.d/java/20ibm-jdk-1.3.0) 151[ibm-jdk-1.3.0] IBM JDK 1.3.0 (/etc/env.d/java/20ibm-jdk-1.3.0)
114[ibm-jdk-1.3.1] IBM JDK 1.3.1 (/etc/env.d/java/20ibm-jdk-1.3.1) 152[ibm-jdk-1.3.1] IBM JDK 1.3.1 (/etc/env.d/java/20ibm-jdk-1.3.1)
115[ibm-jre-1.3.1] IBM JRE 1.3.1 (/etc/env.d/java/20ibm-jre-1.3.1) 153[ibm-jre-1.3.1] IBM JRE 1.3.1 (/etc/env.d/java/20ibm-jre-1.3.1)
116[sun-jdk-1.4.0] Sun JDK 1.4.0 (/etc/env.d/java/20sun-jdk-1.4.0) 154[sun-jdk-1.4.0] Sun JDK 1.4.0 (/etc/env.d/java/20sun-jdk-1.4.0)
117</pre> 155</pre>
118 156
119<p> 157<p>
120The name in the brackets <path>"[]"</path> is the handle or ID for that 158The name in the brackets <path>"[]"</path> is the handle or ID for that
121particular VM. You use pass that ID to <c>java-config --set-system-vm</c>, thus: 159particular VM. You use pass that ID to <c>java-config --set-system-vm</c>. Here is
160an example of how to set the system VM.
122</p> 161</p>
123 162
124<pre caption="Setting the System VM"> 163<pre caption="Setting the System VM">
125# <i>java-config --set-system-vm=ibm-jdk-1.3.1</i> 164# <i>java-config --set-system-vm=ibm-jdk-1.3.1</i>
126Now using IBM JDK 1.3.1 (/etc/env.d/java/20ibm-jdk-1.3.1) 165Now using IBM JDK 1.3.1 (/etc/env.d/java/20ibm-jdk-1.3.1)
127</pre> 166</pre>
128 167
129<note> 168<note>
130You will have to be root to run --set-system-vm. 169You will have to be root to run --set-system-vm.
131</note> 170</note>
132 171
133<p> 172<p>
134Once you have issued <c>java-config --set-system-vm</c> with a particular VM ID, 173Once you have issued <c>java-config --set-system-vm</c> with a particular VM ID,
135you will need to regenerate your /etc/profile.env, thus: 174you will need to regenerate your /etc/profile.env. You can do it like this:
136</p> 175</p>
137 176
138<pre caption="Regenerating /etc/profile.env" > 177<pre caption="Regenerating /etc/profile.env" >
139# <i>env-update</i> 178# <i>env-update</i>
140</pre> 179</pre>
141 180
142<p> 181<p>
143After this, you will either want to relogin, or resource 182After this, you will either want to relogin, or resource
144<path>/etc/profile</path> into your environment. 183<path>/etc/profile</path> into your environment.
145</p> 184</p>
146 185
147<p> 186<p>
148As a regular user, you can use <c>java-config --set-user-vm</c>, which will 187As a regular user, you can use <c>java-config --set-user-vm</c>, which will
149create <path>$HOME/.gentoo/java-env</path> with all required env vars. You would 188create <path>~/.gentoo/java-env</path> with all required env vars. You would
150normally source this from your shell's startup script 189normally source this from your shell's startup script
151(<path>$HOME/.zshenv</path> in my case). 190(generally <path>~/.bashrc</path>).
152</p> 191</p>
153 192
154</body> 193</body>
155</section> 194</section>
156 195
157<section> 196<section>
158<title>Setting a default CLASSPATH</title> 197<title>Setting a default CLASSPATH</title>
159<body> 198<body>
160 199
161<p> 200<p>
162<c>java-config</c> can also be used to set a system-wide default CLASSPATH, and 201<c>java-config</c> can also be used to set a system-wide default CLASSPATH, and
163of course a user-specific default CLASSPATH. 202of course a user-specific default CLASSPATH.
164</p> 203</p>
165 204
166<p> 205<p>
167First you want to list available java libraries that might be interesting to put 206First you want to list available java libraries that might be interesting to put
168in your CLASSPATH, thus: 207in your CLASSPATH. Here is an example of output:
169</p> 208</p>
170 209
171<pre caption="Listing classes"> 210<pre caption="Listing classes">
172# <i>java-config --list-available-packages</i> 211# <i>java-config --list-available-packages</i>
173[ant] No description (/usr/share/ant/classpath.env) 212[bsh] BeanShell is a small, free, embeddable, Java
174[java-gnome] No description (/usr/share/java-gnome/classpath.env) 213source interpreter with object scripting language
175[java-gtk] No description (/usr/share/java-gtk/classpath.env) 214features. (/usr/share/bsh/package.env)
176[log4j] "" (/usr/share/log4j/package.env) 215[oro] A set of text-processing Java classes that
216provide Perl5 compatible regular expressions, AWK-like
217regular expressions, glob expressions, and utility
218classes for performing substitutions, splits, filtering
219filenames, etc. (/usr/share/oro/package.env)
220[bcel] The Byte Code Engineering Library: analyze, create,
221manipulate Java class files (/usr/share/bcel/package.env)
222[jsch] JSch is a pure Java implementation of SSH2.
223(/usr/share/jsch/package.env)
224...
177</pre> 225</pre>
178
179<note>
180None of these packages have a proper description. That is something that will be
181implemented in the not-so-distant future.
182</note>
183 226
184<p> 227<p>
185Again, the name in brackets <path>"[]"</path> are the IDs that you have to pass 228Again, the name in brackets <path>"[]"</path> are the IDs that you have to pass
186to <c>java-config --set-system-classpath</c>, thus: 229to <c>java-config --set-system-classpath</c>. Here is an example:
187</p> 230</p>
188 231
189<pre caption="Setting classpaths"> 232<pre caption="Setting classpaths">
190# <i>java-config --set-system-classpath=log4j,java-gtk,java-gnome</i> 233# <i>java-config --set-system-classpath=log4j,java-gtk,java-gnome</i>
191</pre> 234</pre>
192 235
193<note> 236<note>
194The current directory (.) will not be part of the system classpath, as that 237The current directory (.) will not be part of the system classpath, as that
195should be added in root's login profile. 238should be added in root's login profile.
196</note> 239</note>
197 240
198<p> 241<p>
199Again, you will want to run <c>env-update</c> to update your system's 242Again, you will want to run <c>env-update</c> to update your system's
200environment, and you might also want to relogin or resource the 243environment, and you might also want to relogin or resource the
201<path>/etc/profile</path>. 244<path>/etc/profile</path>.
202</p> 245</p>
203 246
204<p> 247<p>
205For users, <c>java-config --set-user-classpath</c> will create 248For users, <c>java-config --set-user-classpath</c> will create
206<path>$HOME/.gentoo/java-env-classpath</path>, which is automatically included 249<path>~/.gentoo/java-env-classpath</path>, which is automatically included
207by <path>$HOME/.gentoo/java-env</path>. 250by <path>~/.gentoo/java-env</path>.
251</p>
252
253</body>
254</section>
255</chapter>
256
257<chapter>
258<title>USE flags for use with Java</title>
259<section>
260<title>Setting USE flags</title>
261<body>
262
208</p> 263<p>
264For more information regarding USE flags, refer to the
265<uri link="/doc/en/handbook/handbook-x86.xml?part=2&amp;chap=2">USE flags</uri>
266chapter from the Gentoo Handbook.
267</p>
268
269</body>
270</section>
271<section>
272<title>The flags</title>
273<body>
274
275<ul>
276<li>The <b>java</b> flag adds support for Java in a variety of programs.</li>
277<li>The <b>mozilla</b> flag adds support for Mozilla-like browsers (including Firefox)
278if you are using blackdown's Java kit. You will need this for viewing Java applets
279in your Mozilla-like browser.</li>
280</ul>
209 281
210</body> 282</body>
211</section> 283</section>
212</chapter> 284</chapter>
213 285
214<chapter> 286<chapter>
215<title>Additional resources</title> 287<title>Additional resources</title>
216<section> 288<section>
217<title>Off-line resources</title> 289<title>Off-line resources</title>
218<body> 290<body>
219 291
220<ul> 292<ul>
221<li>java-config man page</li> 293<li>java-config man page</li>
222<li><c>java-config --help</c></li> 294<li><c>java-config --help</c></li>
223<li>The <path>/usr/bin/java-config</path> script itself</li> 295<li>The <path>/usr/bin/java-config</path> script itself</li>
224</ul> 296</ul>
225 297
226</body> 298</body>
227</section> 299</section>
228 300
229<section> 301<section>
230<title>Online resources</title> 302<title>Online resources</title>
231<body> 303<body>
232
233<ul> 304<ul>
234<li>The <uri link="http://news.gmane.org/gmane.linux.gentoo.devel" 305<li>The <uri link="http://news.gmane.org/gmane.linux.gentoo.devel"
235>gentoo-dev</uri>, <uri link="http://news.gmane.org/gmane.linux.gentoo.user" 306>gentoo-dev</uri>, <uri link="http://news.gmane.org/gmane.linux.gentoo.user"
236>gentoo-user </uri> mailing list archives</li> 307>gentoo-user </uri> mailing list archives</li>
237<li>#gentoo and #gentoo-java on irc.freenode.net</li> 308<li>#gentoo and #gentoo-java on irc.freenode.net</li>
309<li><uri link="http://en.wikipedia.org/wiki/Java_programming_language">Wikipedia's entry for Java</uri></li>
238</ul> 310</ul>
239 311
240</body> 312</body>
241</section> 313</section>
242</chapter> 314</chapter>
243</guide> 315</guide>

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.20