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