| 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.9 2003/11/15 00:35:19 neysx 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> |
| 5 | <author title="Author and Editor"> |
7 | <author title="Author and Editor"> |
| 6 | <mail link="karltk@gentoo.org">Karl Trygve Kalleberg</mail> |
8 | <mail link="karltk@gentoo.org">Karl Trygve Kalleberg</mail> |
| 7 | </author> |
9 | </author> |
| 8 | |
10 | |
| 9 | <abstract> |
11 | <abstract> |
| 10 | Users' and Developers' Guide to Java in Gentoo |
12 | Users' and Developers' Guide to Java in Gentoo |
| 11 | </abstract> |
13 | </abstract> |
| 12 | |
14 | |
|
|
15 | <license/> |
|
|
16 | |
| 13 | <version>0.1.1</version> |
17 | <version>0.1.2</version> |
| 14 | <date>June 25, 2002</date> |
18 | <date>September 4, 2002</date> |
| 15 | |
19 | |
| 16 | <chapter> |
20 | <chapter> |
| 17 | |
|
|
| 18 | <title>Installing a JDK/JRE</title> |
21 | <title>Installing a JDK/JRE</title> |
| 19 | <section> |
22 | <section> |
| 20 | <title>Overview</title> |
23 | <title>Overview</title> |
| 21 | <body> |
24 | <body> |
|
|
25 | |
| 22 | <p>Gentoo provides numerous JDKs and JREs. The default is the |
26 | <p>Gentoo provides numerous JDKs and JREs. The default is the |
| 23 | Blackdown JDK/JRE pair, as it is freely (beer) available without any |
27 | Blackdown JDK/JRE pair, as it is freely (beer) available without any |
| 24 | registration fuss.</p> |
28 | registration fuss. |
|
|
29 | </p> |
| 25 | |
30 | |
| 26 | <note>As kaffe becomes a JRE/JDK drop-in replacement, that will most |
31 | <note>As kaffe becomes a JRE/JDK drop-in replacement, that will most |
| 27 | likely become our default.</note> |
32 | likely become our default. |
|
|
33 | </note> |
| 28 | |
34 | |
| 29 | <p>Both the Sun JDK/JRE and the IBM JDK/JRE are generally faster, but |
35 | <p>Both the Sun JDK/JRE and the IBM JDK/JRE are generally faster, but |
| 30 | getting them is a bit more work, as you are required to read and |
36 | getting them is a bit more work, as you are required to read and |
| 31 | accept their license before downloading (IBM additionally requires you |
37 | accept their license before downloading (IBM additionally requires you |
| 32 | to register).</p> |
38 | to register). |
|
|
39 | </p> |
| 33 | |
40 | |
| 34 | <p>Our ebuilds for the Sun and IBM JDK/JREs will notify you of where |
41 | <p>Our ebuilds for the Sun and IBM JDK/JREs will notify you of where |
| 35 | to go to download them.</p> |
42 | to go to download them. |
|
|
43 | </p> |
|
|
44 | |
| 36 | </body> |
45 | </body> |
| 37 | </section> |
46 | </section> |
| 38 | |
47 | |
| 39 | <section> |
48 | <section> |
| 40 | <title>Installing the Sun/IBM JDK/JREs</title> |
49 | <title>Installing the Sun/IBM JDK/JREs</title> |
| 41 | <body> |
50 | <body> |
|
|
51 | |
| 42 | <p>If you run <c>emerge dev-java/sun-jdk-1.3.1</c> or <c>emerge |
52 | <p>If you run <c>emerge sun-jdk-1.3.1</c> or <c>emerge |
| 43 | dev-java/ibm-jdk-1.3.1</c>, you will be notified that you are required |
53 | ibm-jdk-1.3.1</c>, you will be notified that you are required |
| 44 | to download the actual tarballs yourself. This has to do with license |
54 | to download the actual tarballs yourself. This has to do with license |
| 45 | restrictions for the Sun JDK/JRE (online click-wrap license) and |
55 | restrictions for the Sun JDK/JRE (online click-wrap license) and |
| 46 | registration issues with the IBM JDK/JRE.</p> |
56 | registration issues with the IBM JDK/JRE. |
|
|
57 | </p> |
| 47 | |
58 | |
| 48 | <note>There is also a dev-java/sun-jdk-1.4.0, but not all packages |
59 | <note>There is also a sun-jdk-1.4.0, but not all packages |
| 49 | work nicely with Java 1.4, so you're on your own if you use the 1.4.0 |
60 | work nicely with Java 1.4, so you're on your own if you use the 1.4.0 |
| 50 | JDK.</note> |
61 | JDK. |
|
|
62 | </note> |
| 51 | |
63 | |
| 52 | <p>You should download the indicated file(s) into |
64 | <p>You should download the indicated file(s) into |
| 53 | <path>/usr/portage/distfiles</path>. Once that is done, you can rerun |
65 | <path>/usr/portage/distfiles</path>. Once that is done, you can rerun |
| 54 | the emerge command, then the JDK/JRE will be installed properly into |
66 | the emerge command, then the JDK/JRE will be installed properly into |
| 55 | <path>/opt</path>.</p> |
67 | <path>/opt</path>. |
|
|
68 | </p> |
|
|
69 | |
| 56 | </body> |
70 | </body> |
| 57 | </section> |
71 | </section> |
| 58 | </chapter> |
72 | </chapter> |
| 59 | |
73 | |
| 60 | <chapter> |
74 | <chapter> |
| 61 | <title>Configuring your JDK/JRE</title> |
75 | <title>Configuring your JDK/JRE</title> |
|
|
76 | |
| 62 | <section> |
77 | <section> |
| 63 | <title>Overview</title> |
78 | <title>Overview</title> |
|
|
79 | |
| 64 | <body> |
80 | <body> |
|
|
81 | |
| 65 | <p>Gentoo has the ability to have multiple JDKs and JREs installed |
82 | <p>Gentoo has the ability to have multiple JDKs and JREs installed |
| 66 | without them conflicting. There are a few caveats to this, as noted |
83 | without them conflicting. There are a few caveats to this, as noted |
| 67 | below.</p> |
84 | below. |
|
|
85 | </p> |
| 68 | |
86 | |
| 69 | <p>Using the <c>java-config</c> tool, you can set the system-wide |
87 | <p>Using the <c>java-config</c> tool, you can set the system-wide |
| 70 | default if you have root access. Users can also use <c>java-config</c> |
88 | default if you have root access. Users can also use <c>java-config</c> |
| 71 | to set up their own personal default, that is different from the |
89 | to set up their own personal default, that is different from the |
| 72 | system-wide default.</p> |
90 | system-wide default. |
|
|
91 | </p> |
|
|
92 | |
| 73 | </body> |
93 | </body> |
| 74 | </section> |
94 | </section> |
| 75 | |
95 | |
| 76 | <section> |
96 | <section> |
| 77 | <title>Setting a default JDK/JRE</title> |
97 | <title>Setting a default JDK/JRE</title> |
| 78 | <body> |
98 | <body> |
|
|
99 | |
| 79 | <p>Running the command <c>java-config --list-available-vms</c> will |
100 | <p>Running the command <c>java-config --list-available-vms</c> will |
| 80 | give you a list of all availble JREs and JDKs on your system, thus:</p> |
101 | give you a list of all availble JREs and JDKs on your system, thus:</p> |
| 81 | <pre> |
102 | |
|
|
103 | <pre caption = "Listing available VMs"> |
| 82 | [%1 ~] java-config --list-available-vms |
104 | [%1 ~] java-config --list-available-vms |
| 83 | [blackdown-jdk-1.3.1] Blackdown JDK 1.3.1 (/etc/env.d/java/20blackdown-jdk-1.3.1) |
105 | [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) |
106 | [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) |
107 | [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) |
108 | [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) |
109 | [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) |
110 | [sun-jdk-1.4.0] Sun JDK 1.4.0 (/etc/env.d/java/20sun-jdk-1.4.0) |
| 89 | </pre> |
111 | </pre> |
|
|
112 | |
| 90 | <p>The name in the brackets <path>"[]"</path> is the handle or ID for |
113 | <p>The name in the brackets <path>"[]"</path> is the handle or ID for |
| 91 | that particular VM. You use pass that ID to <c>java-config |
114 | that particular VM. You use pass that ID to <c>java-config |
| 92 | --set-system-vm</c>, thus:</p> |
115 | --set-system-vm</c>, thus: |
| 93 | <pre> |
116 | </p> |
|
|
117 | |
|
|
118 | <pre caption = "Setting the System VM"> |
| 94 | [#1 ~] java-config --set-system-vm=ibm-jdk-1.3.1 |
119 | [#1 ~] java-config --set-system-vm=ibm-jdk-1.3.1 |
| 95 | Now using IBM JDK 1.3.1 (/etc/env.d/java/20ibm-jdk-1.3.1) |
120 | Now using IBM JDK 1.3.1 (/etc/env.d/java/20ibm-jdk-1.3.1) |
| 96 | </pre> |
121 | </pre> |
| 97 | |
122 | |
| 98 | <note>You will have to be root to run --set-system-vm</note> |
123 | <note>You will have to be root to run --set-system-vm |
|
|
124 | </note> |
| 99 | |
125 | |
| 100 | <p>Once you have issued <c>java-config --set-system-vm</c> with a |
126 | <p>Once you have issued <c>java-config --set-system-vm</c> with a |
| 101 | particular VM ID, you will need to regenerate your /etc/profile.env, |
127 | particular VM ID, you will need to regenerate your /etc/profile.env, |
| 102 | thus:</p> |
128 | thus: |
| 103 | <pre> |
129 | </p> |
|
|
130 | |
|
|
131 | <pre caption = "Regenerating /etc/profile.env" > |
| 104 | [#1 ~] env-update |
132 | [#1 ~] env-update |
| 105 | </pre> |
133 | </pre> |
| 106 | |
134 | |
| 107 | <p>After this, you will either want to relogin, or resource |
135 | <p>After this, you will either want to relogin, or resource |
| 108 | <path>/etc/profile</path> into your environment.</p> |
136 | <path>/etc/profile</path> into your environment. |
|
|
137 | </p> |
| 109 | |
138 | |
| 110 | <p>As a regular user, you can use <c>java-config --set-user-vm</c>, |
139 | <p>As a regular user, you can use <c>java-config --set-user-vm</c>, |
| 111 | which will create <path>$HOME/.gentoo/java-env</path> with all |
140 | which will create <path>$HOME/.gentoo/java-env</path> with all |
| 112 | required env vars. You would normally source this from your shell's |
141 | required env vars. You would normally source this from your shell's |
| 113 | startup script (<path>$HOME/.zshenv</path> in my case).</p> |
142 | startup script (<path>$HOME/.zshenv</path> in my case).</p> |
|
|
143 | |
| 114 | </body> |
144 | </body> |
| 115 | </section> |
145 | </section> |
| 116 | |
146 | |
| 117 | <section> |
147 | <section> |
| 118 | <title>Setting a default CLASSPATH</title> |
148 | <title>Setting a default CLASSPATH</title> |
| 119 | <body> |
149 | <body> |
|
|
150 | |
| 120 | <p><c>java-config</c> can also be used to set a system-wide default |
151 | <p><c>java-config</c> can also be used to set a system-wide default |
| 121 | CLASSPATH, and of course a user-specific default CLASSPATH.</p> |
152 | CLASSPATH, and of course a user-specific default CLASSPATH. |
|
|
153 | </p> |
| 122 | |
154 | |
| 123 | <p>First you want to list available java libraries that might be |
155 | <p>First you want to list available java libraries that might be |
| 124 | interesting to put in your CLASSPATH, thus:</p> |
156 | interesting to put in your CLASSPATH, thus: |
| 125 | <pre> |
157 | </p> |
|
|
158 | |
|
|
159 | <pre caption = "Listing classes"> |
| 126 | [%1 ~] java-config --list-available-packages |
160 | [%1 ~] java-config --list-available-packages |
| 127 | [ant] No description (/usr/share/ant/classpath.env) |
161 | [ant] No description (/usr/share/ant/classpath.env) |
| 128 | [java-gnome] No description (/usr/share/java-gnome/classpath.env) |
162 | [java-gnome] No description (/usr/share/java-gnome/classpath.env) |
| 129 | [java-gtk] No description (/usr/share/java-gtk/classpath.env) |
163 | [java-gtk] No description (/usr/share/java-gtk/classpath.env) |
| 130 | [log4j] "" (/usr/share/log4j/package.env) |
164 | [log4j] "" (/usr/share/log4j/package.env) |
| 131 | </pre> |
165 | </pre> |
| 132 | |
166 | |
| 133 | <note>None of these packages have a proper description. That is |
167 | <note>None of these packages have a proper description. That is |
| 134 | something that will be implemented in the not-so-distant |
168 | something that will be implemented in the not-so-distant |
| 135 | future.</note> |
169 | future. |
|
|
170 | </note> |
| 136 | |
171 | |
| 137 | <p>Again, the name in brackets <path>"[]"</path> are the IDs that you |
172 | <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> |
173 | have to pass to <c>java-config --set-system-classpath</c>, thus: |
| 139 | <pre> |
174 | </p> |
|
|
175 | |
|
|
176 | <pre caption = "Setting classpaths"> |
| 140 | java-config --set-system-classpath=log4j,java-gtk,java-gnome |
177 | java-config --set-system-classpath=log4j,java-gtk,java-gnome |
| 141 | </pre> |
178 | </pre> |
|
|
179 | |
| 142 | <note>The current directory (.) will not be part of the system classpath, |
180 | <note>The current directory (.) will not be part of the system classpath, |
| 143 | as that should be added in root's login profile.</note> |
181 | as that should be added in root's login profile. |
|
|
182 | </note> |
|
|
183 | |
| 144 | <p>Again, you will want to run <c>env-update</c> to update your |
184 | <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 |
185 | system's environment, and you might also want to relogin or resource |
| 146 | the <path>/etc/profile</path>.</p> |
186 | the <path>/etc/profile</path>. |
|
|
187 | </p> |
|
|
188 | |
| 147 | <p>For users, <c>java-config --set-user-classpath</c> will create |
189 | <p>For users, <c>java-config --set-user-classpath</c> will create |
| 148 | <path>$HOME/.gentoo/java-env-classpath</path>, which is automatically |
190 | <path>$HOME/.gentoo/java-env-classpath</path>, which is automatically |
| 149 | included by <path>$HOME/.gentoo/java-env</path>.</p> |
191 | included by <path>$HOME/.gentoo/java-env</path>. |
|
|
192 | </p> |
|
|
193 | |
| 150 | </body> |
194 | </body> |
| 151 | </section> |
195 | </section> |
| 152 | </chapter> |
196 | </chapter> |
| 153 | |
197 | |
| 154 | <chapter> |
198 | <chapter> |
| 155 | <title>Additional resources</title> |
199 | <title>Additional resources</title> |
| 156 | <section> |
200 | <section> |
| 157 | <title>Off-line resources</title> |
201 | <title>Off-line resources</title> |
|
|
202 | |
| 158 | <body> |
203 | <body> |
| 159 | <ul> |
204 | |
|
|
205 | <ul> |
| 160 | <li>java-config man page</li> |
206 | <li>java-config man page</li> |
| 161 | <li><c>java-config --help</c></li> |
207 | <li><c>java-config --help</c></li> |
| 162 | <li>The <path>/usr/bin/java-config</path> script itself</li> |
208 | <li>The <path>/usr/bin/java-config</path> script itself</li> |
| 163 | </ul> |
209 | </ul> |
|
|
210 | |
| 164 | </body> |
211 | </body> |
| 165 | </section> |
212 | </section> |
|
|
213 | |
| 166 | <section> |
214 | <section> |
| 167 | <title>Online resources</title> |
215 | <title>Online resources</title> |
|
|
216 | |
| 168 | <body> |
217 | <body> |
| 169 | <ul> |
218 | |
| 170 | <li>The <uri link="http://lists.gentoo.org/pipermail/gentoo-dev/"> |
219 | <ul> |
|
|
220 | <li>The <uri link="http://news.gmane.org/gmane.linux.gentoo.devel"> |
| 171 | gentoo-dev </uri>, |
221 | gentoo-dev </uri>, |
| 172 | <uri link="http://lists.gentoo.org/pipermail/gentoo-user/"> gentoo-user |
222 | <uri link="http://news.gmane.org/gmane.linux.gentoo.user"> gentoo-user |
| 173 | </uri> mailing list archives</li> |
223 | </uri> mailing list archives</li> |
| 174 | <li>#gentoo on irc.openprojects.net</li> |
224 | <li>#gentoo on irc.openprojects.net</li> |
| 175 | </ul> |
225 | </ul> |
|
|
226 | |
| 176 | </body> |
227 | </body> |
| 177 | </section> |
228 | </section> |
| 178 | </chapter> |
229 | </chapter> |
|
|
230 | |
| 179 | <chapter> |
231 | <chapter> |
| 180 | <title>Caveats</title> |
232 | <title>Caveats</title> |
| 181 | <section> |
233 | <section> |
| 182 | <title>General</title> |
234 | <title>General</title> |
|
|
235 | |
| 183 | <body> |
236 | <body> |
|
|
237 | |
| 184 | <p>If you select a JRE as your default VM, you may not have a |
238 | <p>If you select a JRE as your default VM, you may not have a |
| 185 | <c>javac</c> command handy at all times, unless you have manually |
239 | <c>javac</c> command handy at all times, unless you have manually |
| 186 | installed a symlink to take care of that.</p> |
240 | installed a symlink to take care of that. |
|
|
241 | </p> |
| 187 | |
242 | |
| 188 | <p>Jikes will be used to compile some of the largest packages, if it |
243 | <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 |
244 | is available. With time, we hope to be able to compile all |
| 190 | java-dependent packages with Jikes, so some dependencies on the JDK |
245 | java-dependent packages with Jikes, so some dependencies on the JDK |
| 191 | can be replaced with a dependency on the JRE.</p> |
246 | can be replaced with a dependency on the JRE.</p> |
| 192 | |
247 | |
| 193 | <p>With some versions of Portage, doing an <c>emerge --world |
248 | <p>With some versions of Portage, doing an <c>emerge --update world</c> |
| 194 | update</c> will install the JDK regardless if whether you have it |
249 | will install the JDK regardless if whether you have it |
| 195 | installed before or not. This is a known bug addressed in later |
250 | installed before or not. This is a known bug addressed in later |
| 196 | versions of Portage.</p> |
251 | versions of Portage. |
|
|
252 | </p> |
|
|
253 | |
| 197 | </body> |
254 | </body> |
| 198 | </section> |
255 | </section> |
| 199 | </chapter> |
256 | </chapter> |
| 200 | </guide> |
257 | </guide> |