| 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 | |
| … | |
… | |
| 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> |
| 16 | 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. |
| 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> |
| 31 | Gentoo provides numerous JDKs and JREs. The default is the Blackdown JDK/JRE |
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> |
|
|
44 | |
|
|
45 | <p> |
|
|
46 | In order to run Java bytecodes, one needs to have a JRE (Java Runtime Environment) |
|
|
47 | installed. A JRE provides core libraries, a platform dependent Java Virtual Machine, |
|
|
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> |
|
|
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> |
|
|
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 |
| 32 | pair, as it is freely (beer) available without any registration fuss. |
76 | pair, as it is freely (beer) available without any registration fuss. |
| 33 | </p> |
77 | </p> |
| 34 | |
78 | |
| 35 | <note> |
|
|
| 36 | As kaffe becomes a JRE/JDK drop-in replacement, that will most likely become our |
|
|
| 37 | default. |
|
|
| 38 | </note> |
|
|
| 39 | |
|
|
| 40 | <p> |
79 | <p> |
| 41 | Both the Sun JDK/JRE and the IBM JDK/JRE are generally faster, but getting them |
80 | Both the Sun JRE/JDK and the IBM JRE/JDK are generally faster, but getting them |
| 42 | is a bit more work, as you are required to read and accept their license before |
81 | is a bit more work, as you are required to read and accept their license before |
| 43 | downloading (IBM additionally requires you to register). |
82 | downloading (IBM additionally requires you to register). |
| 44 | </p> |
83 | </p> |
| 45 | |
84 | |
| 46 | <p> |
85 | <p> |
| 47 | Our ebuilds for the Sun and IBM JDK/JREs will notify you of where to go to |
86 | Our ebuilds for the Sun and IBM JRE/JDKs will notify you of where to go to |
| 48 | download them. |
87 | download 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> |
| 59 | If you run <c>emerge sun-jdk-1.3.1</c> or <c>emerge ibm-jdk-1.3.1</c>, you will |
98 | If you run <c>emerge =sun-jdk-1.4.2.06</c> or <c>=ibm-jdk-bin-1.4.2</c>, you will |
| 60 | be notified that you are required to download the actual tarballs yourself. This |
99 | be notified that you are required to download the actual tarballs yourself. This |
| 61 | has to do with license restrictions for the Sun JDK/JRE (online click-wrap |
100 | has to do with license restrictions for the Sun JRE/JDK (online click-wrap |
| 62 | license) and registration issues with the IBM JDK/JRE. |
101 | license) and registration issues with the IBM JRE/JDK. |
| 63 | </p> |
102 | </p> |
| 64 | |
103 | |
| 65 | <note> |
104 | <note> |
| 66 | There is also a sun-jdk-1.4.0, but not all packages work nicely with Java 1.4, |
105 | ibm-jdk-bin is currently masked, you may have to unmask it to use it. |
| 67 | so you're on your own if you use the 1.4.0 JDK. |
|
|
| 68 | </note> |
106 | </note> |
| 69 | |
107 | |
| 70 | <p> |
108 | <p> |
| 71 | You should download the indicated file(s) into |
109 | You 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 |
| 73 | command, then the JDK/JRE will be installed properly into <path>/opt</path>. |
111 | command, 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> |
| … | |
… | |
| 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> |
| 105 | Running the command <c>java-config --list-available-vms</c> will give you a list |
143 | Running the command <c>java-config --list-available-vms</c> will give you a list |
| 106 | of all available JREs and JDKs on your system, thus: |
144 | of 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) |
| … | |
… | |
| 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> |
| 120 | The name in the brackets <path>"[]"</path> is the handle or ID for that |
158 | The name in the brackets <path>"[]"</path> is the handle or ID for that |
| 121 | particular VM. You use pass that ID to <c>java-config --set-system-vm</c>, thus: |
159 | particular VM. You use pass that ID to <c>java-config --set-system-vm</c>. Here is |
|
|
160 | an 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> |
| 126 | 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) |
| … | |
… | |
| 130 | You will have to be root to run --set-system-vm. |
169 | You will have to be root to run --set-system-vm. |
| 131 | </note> |
170 | </note> |
| 132 | |
171 | |
| 133 | <p> |
172 | <p> |
| 134 | Once you have issued <c>java-config --set-system-vm</c> with a particular VM ID, |
173 | Once you have issued <c>java-config --set-system-vm</c> with a particular VM ID, |
| 135 | you will need to regenerate your /etc/profile.env, thus: |
174 | you 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> |
| … | |
… | |
| 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> |
| 148 | As a regular user, you can use <c>java-config --set-user-vm</c>, which will |
187 | As a regular user, you can use <c>java-config --set-user-vm</c>, which will |
| 149 | create <path>$HOME/.gentoo/java-env</path> with all required env vars. You would |
188 | create <path>~/.gentoo/java-env</path> with all required env vars. You would |
| 150 | normally source this from your shell's startup script |
189 | normally 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 | |
| … | |
… | |
| 163 | of course a user-specific default CLASSPATH. |
202 | of course a user-specific default CLASSPATH. |
| 164 | </p> |
203 | </p> |
| 165 | |
204 | |
| 166 | <p> |
205 | <p> |
| 167 | First you want to list available java libraries that might be interesting to put |
206 | First you want to list available java libraries that might be interesting to put |
| 168 | in your CLASSPATH, thus: |
207 | in 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) |
213 | source interpreter with object scripting language |
| 175 | [java-gtk] No description (/usr/share/java-gtk/classpath.env) |
214 | features. (/usr/share/bsh/package.env) |
| 176 | [log4j] "" (/usr/share/log4j/package.env) |
215 | [oro] A set of text-processing Java classes that |
|
|
216 | provide Perl5 compatible regular expressions, AWK-like |
|
|
217 | regular expressions, glob expressions, and utility |
|
|
218 | classes for performing substitutions, splits, filtering |
|
|
219 | filenames, etc. (/usr/share/oro/package.env) |
|
|
220 | [bcel] The Byte Code Engineering Library: analyze, create, |
|
|
221 | manipulate 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> |
|
|
| 180 | None of these packages have a proper description. That is something that will be |
|
|
| 181 | implemented in the not-so-distant future. |
|
|
| 182 | </note> |
|
|
| 183 | |
226 | |
| 184 | <p> |
227 | <p> |
| 185 | Again, the name in brackets <path>"[]"</path> are the IDs that you have to pass |
228 | Again, the name in brackets <path>"[]"</path> are the IDs that you have to pass |
| 186 | to <c>java-config --set-system-classpath</c>, thus: |
229 | to <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> |
| … | |
… | |
| 201 | <path>/etc/profile</path>. |
244 | <path>/etc/profile</path>. |
| 202 | </p> |
245 | </p> |
| 203 | |
246 | |
| 204 | <p> |
247 | <p> |
| 205 | For users, <c>java-config --set-user-classpath</c> will create |
248 | For 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 |
| 207 | by <path>$HOME/.gentoo/java-env</path>. |
250 | by <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> |
|
|
264 | For more information regarding USE flags, refer to the |
|
|
265 | <uri link="/doc/en/handbook/handbook-x86.xml?part=2&chap=2">USE flags</uri> |
|
|
266 | chapter 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) |
|
|
278 | if you are using blackdown's Java kit. You will need this for viewing Java applets |
|
|
279 | in your Mozilla-like browser.</li> |
|
|
280 | </ul> |
| 209 | |
281 | |
| 210 | </body> |
282 | </body> |
| 211 | </section> |
283 | </section> |
| 212 | </chapter> |
284 | </chapter> |
| 213 | |
285 | |
| … | |
… | |
| 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> |