| 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.44 2009/10/07 18:14:31 nightmorph Exp $ --> |
|
|
| 3 | <!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> |
2 | <!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> |
|
|
3 | <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/java.xml,v 1.54 2012/07/24 12:12:51 swift Exp $ --> |
| 4 | |
4 | |
| 5 | <guide link="/doc/en/java.xml"> |
5 | <guide> |
| 6 | <title>Gentoo Java Guide</title> |
6 | <title>Gentoo Java Guide</title> |
| 7 | |
7 | |
| 8 | <author title="Author"> |
8 | <author title="Author"> |
| 9 | <mail link="nichoj@gentoo.org">Joshua Nichols</mail> |
9 | <mail link="nichoj@gentoo.org">Joshua Nichols</mail> |
| 10 | </author> |
10 | </author> |
| … | |
… | |
| 22 | |
22 | |
| 23 | <!-- The content of this document is licensed under the CC-BY-SA license --> |
23 | <!-- The content of this document is licensed under the CC-BY-SA license --> |
| 24 | <!-- See http://creativecommons.org/licenses/by-sa/2.5 --> |
24 | <!-- See http://creativecommons.org/licenses/by-sa/2.5 --> |
| 25 | <license/> |
25 | <license/> |
| 26 | |
26 | |
| 27 | <version>0.19</version> |
27 | <version>5</version> |
| 28 | <date>2009-10-07</date> |
28 | <date>2012-07-24</date> |
| 29 | |
29 | |
| 30 | <chapter> |
30 | <chapter> |
| 31 | <title>What is Java?</title> |
31 | <title>What is Java?</title> |
| 32 | <section> |
32 | <section> |
| 33 | <title>Overview</title> |
33 | <title>Overview</title> |
| … | |
… | |
| 55 | </body> |
55 | </body> |
| 56 | </section> |
56 | </section> |
| 57 | </chapter> |
57 | </chapter> |
| 58 | |
58 | |
| 59 | <chapter> |
59 | <chapter> |
| 60 | <title>Before You Begin</title> |
|
|
| 61 | <section> |
|
|
| 62 | <title>Existing installs</title> |
|
|
| 63 | <body> |
|
|
| 64 | |
|
|
| 65 | <p> |
|
|
| 66 | For existing installs, regardless of if you have installed anything Java |
|
|
| 67 | before, make sure you have followed the <uri |
|
|
| 68 | link="/proj/en/java/java-upgrade.xml">Java Upgrade Guide</uri>. |
|
|
| 69 | </p> |
|
|
| 70 | |
|
|
| 71 | </body> |
|
|
| 72 | </section> |
|
|
| 73 | <section> |
|
|
| 74 | <title>New installs</title> |
|
|
| 75 | <body> |
|
|
| 76 | |
|
|
| 77 | <p> |
|
|
| 78 | New installs should require no further preparation. |
|
|
| 79 | </p> |
|
|
| 80 | |
|
|
| 81 | </body> |
|
|
| 82 | </section> |
|
|
| 83 | </chapter> |
|
|
| 84 | |
|
|
| 85 | <chapter> |
|
|
| 86 | <title>Installing a Virtual Machine</title> |
60 | <title>Installing a Virtual Machine</title> |
| 87 | <section> |
61 | <section> |
| 88 | <title>The choices</title> |
62 | <title>The choices</title> |
| 89 | <body> |
63 | <body> |
| 90 | |
64 | |
| … | |
… | |
| 98 | <th>Vendor</th> |
72 | <th>Vendor</th> |
| 99 | <th>JDK</th> |
73 | <th>JDK</th> |
| 100 | <th>JRE</th> |
74 | <th>JRE</th> |
| 101 | </tr> |
75 | </tr> |
| 102 | <tr> |
76 | <tr> |
| 103 | <ti>The Blackdown Java Kit</ti> |
77 | <ti>The IcedTea Open Java SE (formerly icedtea6-bin)</ti> |
| 104 | <ti>dev-java/blackdown-jdk</ti> |
78 | <ti>dev-java/icedtea-bin</ti> |
| 105 | <ti>dev-java/blackdown-jre</ti> |
79 | <ti /> |
| 106 | </tr> |
|
|
| 107 | <tr> |
80 | </tr> |
|
|
81 | <tr> |
|
|
82 | <ti>Oracle's Java 7 SE</ti> |
|
|
83 | <ti>dev-java/oracle-jdk-bin</ti> |
|
|
84 | <ti>dev-java/oracle-jre-bin</ti> |
|
|
85 | </tr> |
|
|
86 | <tr> |
| 108 | <ti>Sun's Java Kit</ti> |
87 | <ti>Sun's Java 6 SE</ti> |
| 109 | <ti>dev-java/sun-jdk</ti> |
88 | <ti>dev-java/sun-jdk</ti> |
| 110 | <ti>dev-java/sun-jre-bin</ti> |
89 | <ti>dev-java/sun-jre-bin</ti> |
| 111 | </tr> |
90 | </tr> |
| 112 | <tr> |
91 | <tr> |
| 113 | <ti>The IBM Java Kit</ti> |
92 | <ti>The IBM Java SE</ti> |
| 114 | <ti>dev-java/ibm-jdk-bin</ti> |
93 | <ti>dev-java/ibm-jdk-bin</ti> |
| 115 | <ti>dev-java/ibm-jre-bin</ti> |
94 | <ti>dev-java/ibm-jre-bin</ti> |
| 116 | </tr> |
|
|
| 117 | <tr> |
|
|
| 118 | <ti>BEA WebLogic's J2SE Development Kit</ti> |
|
|
| 119 | <ti>dev-java/jrockit-jdk-bin</ti> |
|
|
| 120 | </tr> |
95 | </tr> |
| 121 | </table> |
96 | </table> |
| 122 | |
97 | |
| 123 | <!-- |
98 | <!-- |
| 124 | TODO: list free implementations? |
99 | TODO: list free implementations? |
| 125 | note about not drop-in replacements |
100 | note about not drop-in replacements |
| 126 | kaffe/sablevm/gcj/jamvm |
101 | kaffe/sablevm/gcj/jamvm |
| 127 | --> |
102 | --> |
| 128 | <p> |
|
|
| 129 | The default for Java 1.6 is the Sun JRE/JDK pair. |
|
|
| 130 | </p> |
|
|
| 131 | |
|
|
| 132 | </body> |
103 | </body> |
| 133 | </section> |
104 | </section> |
| 134 | <section> |
105 | <section> |
| 135 | <title>Installing a JRE/JDKs</title> |
106 | <title>Installing a JRE/JDKs</title> |
| 136 | <body> |
107 | <body> |
| … | |
… | |
| 139 | To install your profile's default JDK, you can run <c>emerge virtual/jdk</c>. |
110 | To install your profile's default JDK, you can run <c>emerge virtual/jdk</c>. |
| 140 | Or to install your profile's default JRE, you can <c>emerge virtual/jre</c>. |
111 | Or to install your profile's default JRE, you can <c>emerge virtual/jre</c>. |
| 141 | </p> |
112 | </p> |
| 142 | |
113 | |
| 143 | <p> |
114 | <p> |
| 144 | In recent events, Sun has relicensed their JDK and JRE under a more Linux |
115 | Some JDKs and JREs, including the Sun packages, require accepting an End User |
| 145 | distro friendly license. As a result, Sun releases Java 1.5 and onwards are |
116 | License Agreement, or EULA. If its license (such as dlj-1.1) is not listed in |
| 146 | freely downloadable, without any further hassle. |
117 | ACCEPT_LICENSE in <path>/etc/portage/make.conf</path>, then you won't be able to install |
|
|
118 | the JDK/JRE. For more information on how to add acceptable licenses to |
|
|
119 | <path>make.conf</path>, please read the <uri |
|
|
120 | link="/doc/en/handbook/handbook-x86.xml?part=2&chap=1#doc_chap4">Portage |
|
|
121 | Handbook</uri>. |
|
|
122 | </p> |
|
|
123 | |
|
|
124 | <p> |
|
|
125 | To avoid any restrictive license hassle, consider installing |
|
|
126 | <c>icedtea-bin</c>, which is an open Java implementation from the OpenJDK |
|
|
127 | project. |
| 147 | </p> |
128 | </p> |
| 148 | |
129 | |
| 149 | <note> |
130 | <note> |
| 150 | A JDK also includes a JRE, so if you install a JDK you shouldn't have to also |
131 | A JDK also includes a JRE, so if you install a JDK you shouldn't have to also |
| 151 | have to install a JRE. |
132 | have to install a JRE. |
| … | |
… | |
| 208 | </p> |
189 | </p> |
| 209 | |
190 | |
| 210 | <pre caption="Listing available VMs"> |
191 | <pre caption="Listing available VMs"> |
| 211 | # <i>java-config --list-available-vms</i> |
192 | # <i>java-config --list-available-vms</i> |
| 212 | The following VMs are available for generation-2: |
193 | The following VMs are available for generation-2: |
| 213 | 1) Blackdown JDK 1.4.2.03 [blackdown-jdk-1.4.2] <comment>(Build Only)</comment> |
|
|
| 214 | 2) Blackdown JRE 1.4.2.03 [blackdown-jre-1.4.2] <comment>(Build Only)</comment> |
|
|
| 215 | 3) IcedTea6-bin 1.4.1 [icedtea6-bin] |
194 | 1) IcedTea-bin 1.10.4 [icedtea-bin] |
| 216 | 4) Sun JDK 1.5.0.20 [sun-jdk-1.5] <comment>(Build Only)</comment> |
195 | 2) Sun JDK 1.5.0.20 [sun-jdk-1.5] <comment>(Build Only)</comment> |
| 217 | *) Sun JDK 1.6.0.16 [sun-jdk-1.6] |
196 | *) Sun JDK 1.6.0.16 [sun-jdk-1.6] |
| 218 | </pre> |
197 | </pre> |
| 219 | |
198 | |
| 220 | <note> |
199 | <note> |
| 221 | VMs marked as Build Only may contain security vulnerabilities and/or be EOL. |
200 | VMs marked as Build Only may contain security vulnerabilities and/or be EOL. |
| … | |
… | |
| 231 | --set-system-vm</c>. Here is an example of how to set the system VM. |
210 | --set-system-vm</c>. Here is an example of how to set the system VM. |
| 232 | </p> |
211 | </p> |
| 233 | |
212 | |
| 234 | <pre caption="Setting the System VM"> |
213 | <pre caption="Setting the System VM"> |
| 235 | <comment>(By handle (preferred))</comment> |
214 | <comment>(By handle (preferred))</comment> |
| 236 | # <i>java-config --set-system-vm blackdown-jdk-1.4</i> |
215 | # <i>java-config --set-system-vm sun-jdk-1.6</i> |
| 237 | Now using blackdown-jdk-1.4 as your generation-2 system JVM |
216 | Now using sun-jdk-1.6 as your generation-2 system JVM |
| 238 | WARNING: blackdown-jdk-1.4 is marked as a build-only JVM. Using this vm is not recommended. |
|
|
| 239 | <comment>(By number)</comment> |
217 | <comment>(By number)</comment> |
| 240 | # <i>java-config --set-system-vm 5</i> |
218 | # <i>java-config --set-system-vm 3</i> |
| 241 | Now using sun-jdk-1.6 as your generation-2 system JVM |
219 | Now using sun-jdk-1.6 as your generation-2 system JVM |
| 242 | </pre> |
220 | </pre> |
| 243 | |
221 | |
| 244 | <p> |
222 | <p> |
| 245 | As a regular user, you can use <c>java-config --set-user-vm</c>. |
223 | As a regular user, you can use <c>java-config --set-user-vm</c>. |
| … | |
… | |
| 269 | </p> |
247 | </p> |
| 270 | |
248 | |
| 271 | </body> |
249 | </body> |
| 272 | </section> |
250 | </section> |
| 273 | <section id="preferred-vm"> |
251 | <section id="preferred-vm"> |
| 274 | <title>Preferred VM</title> |
252 | <title>Preferred Build VM</title> |
| 275 | <body> |
253 | <body> |
| 276 | |
254 | |
| 277 | <p> |
|
|
| 278 | While merging Java packages, the VM can and will be switched as necessary. |
|
|
| 279 | </p> |
255 | <p> |
| 280 | |
256 | While merging Java packages, the VM used for building can sometimes be different |
|
|
257 | from the one currently set as the system VM. |
| 281 | <p> |
258 | </p> |
| 282 | Because of the wide variety of available VMs, we do not have the resources to |
259 | |
| 283 | test and verify every package works on all of them. So to ensure that every |
260 | <p> |
| 284 | packages merges smoothly, we have defined a list of <e>default/supported |
261 | This merge time VM switching is needed when, for example, your system-vm is |
|
|
262 | set to a 1.6 VM and the package you are merging requires a 1.5 VM. While merging |
|
|
263 | it will select and use a 1.5 VM, leaving your system-vm choice intact. |
|
|
264 | </p> |
|
|
265 | |
|
|
266 | <p> |
|
|
267 | To define which VM is selected when a switch is needed, we have created a list of <e>default/supported |
| 285 | VMs</e> per arch. You can find them in |
268 | VMs</e> per arch. You can find them in |
| 286 | <path>/usr/share/java-config-2/config/jdk-defaults.conf</path>. When you are |
269 | <path>/usr/share/java-config-2/config/jdk-defaults.conf</path>. |
| 287 | merging a Java package, and it detects one of the VM in that file is installed, |
|
|
| 288 | it will automatically use that VM, instead of the system-vm. |
|
|
| 289 | </p> |
|
|
| 290 | |
|
|
| 291 | <p> |
270 | </p> |
| 292 | The merge time VM switching is also needed when, for example, your system-vm is |
271 | |
| 293 | set a 1.4 VM and the package you are merging requires a 1.5 VM. While merging |
|
|
| 294 | it will use the preferred 1.5 VM, leaving your system-vm choice intact. |
|
|
| 295 | </p> |
272 | <p> |
| 296 | |
273 | You can override these defaults (and even your selected system VM) in |
| 297 | <p> |
|
|
| 298 | Of course, Gentoo is all about choice, so you can override these defaults in |
|
|
| 299 | <path>/etc/java-config-2/build/jdk.conf</path> and have complete control over |
274 | <path>/etc/java-config-2/build/jdk.conf</path> and have complete control over |
| 300 | which VM will get used. Some examples: |
275 | which VM will get used for merging. Some examples: |
| 301 | </p> |
276 | </p> |
| 302 | |
277 | |
| 303 | <pre caption="Example /etc/java-config-2/build/jdk.conf"> |
278 | <pre caption="Example /etc/java-config-2/build/jdk.conf"> |
| 304 | <comment>(I always want it to use a sun-jdk, ie sun-jdk-1.4 for 1.4, sun-jdk-1.5 for 1.5, etc)</comment> |
279 | <comment>(I always want it to use a sun-jdk, ie sun-jdk-1.4 for 1.4, sun-jdk-1.5 for 1.5, etc)</comment> |
| 305 | *=sun-jdk |
280 | *=sun-jdk |
| … | |
… | |
| 310 | *=sun-jdk-1.5 |
285 | *=sun-jdk-1.5 |
| 311 | </pre> |
286 | </pre> |
| 312 | |
287 | |
| 313 | <pre caption="Example /etc/java-config-2/build/jdk.conf"> |
288 | <pre caption="Example /etc/java-config-2/build/jdk.conf"> |
| 314 | <comment># For 1.3 I prefer sun-jdk 1.4 but when it is not available, use ibm-jdk-bin, |
289 | <comment># For 1.3 I prefer sun-jdk 1.4 but when it is not available, use ibm-jdk-bin, |
| 315 | # For 1.4, use blackdown-jdk, and for 1.5, use sun-jdk </comment> |
290 | # For 1.5, use sun-jdk </comment> |
| 316 | 1.3=sun-jdk-1.4 ibm-jdk-bin |
291 | 1.3=sun-jdk-1.4 ibm-jdk-bin |
| 317 | 1.4=blackdown-jdk |
|
|
| 318 | 1.5=sun-jdk |
292 | 1.5=sun-jdk |
| 319 | </pre> |
293 | </pre> |
| 320 | |
294 | |
| 321 | <warn> |
295 | <warn> |
| 322 | You do not have to edit this file. If you change these options to use a |
296 | You do not <e>have</e> to edit this file. If you change these options to use a |
| 323 | unsupported VM, things could possibly break. Bugs reported with a unsupported |
297 | unsupported VM, things could possibly break. Because of the wide variety of |
|
|
298 | available VMs, we do not have the resources to test and verify every package |
|
|
299 | works on all of them. Bugs reported with a unsupported VM won't be prioritized |
| 324 | VM won't be prioritized as much as bugs present within supported VMs. |
300 | as much as bugs present within supported VMs. |
| 325 | </warn> |
301 | </warn> |
| 326 | |
302 | |
| 327 | </body> |
303 | </body> |
| 328 | </section> |
304 | </section> |
| 329 | </chapter> |
305 | </chapter> |
| … | |
… | |
| 332 | <title>Compilers</title> |
308 | <title>Compilers</title> |
| 333 | <section> |
309 | <section> |
| 334 | <body> |
310 | <body> |
| 335 | |
311 | |
| 336 | <p> |
312 | <p> |
| 337 | The standard Java compiler used for building is javac, which comes with each |
313 | The standard Java compiler used for building is <c>javac</c>, which comes with |
| 338 | JDK. In addition to configuring the VM used at build time, it is also possible |
314 | each JDK. In addition to configuring the VM used at build time, it is also |
| 339 | configure which compiler is used. Essentially, you define a list your |
315 | possible configure which compiler is used. Essentially, you define a list your |
| 340 | preference for which compiler to use in |
316 | preference for which compiler to use in |
| 341 | <path>/etc/java-config-2/build/compilers.conf</path>. |
317 | <path>/etc/java-config-2/build/compilers.conf</path>. |
| 342 | </p> |
318 | </p> |
| 343 | |
319 | |
| 344 | <pre caption="/etc/java-config-2/build/compilers.conf"> |
320 | <pre caption="/etc/java-config-2/build/compilers.conf"> |
| 345 | # If the ebuild supports it |
321 | # If the ebuild supports it |
| 346 | # it will check the COMPILERS var front to back and |
322 | # it will check the COMPILERS var front to back and |
| 347 | # use the first compiler that is installed |
323 | # use the first compiler that is installed |
| 348 | |
324 | |
| 349 | COMPILERS="ecj-3.1 jikes javac" |
325 | COMPILERS="ecj-X.Y jikes javac" |
| 350 | </pre> |
326 | </pre> |
| 351 | |
327 | |
| 352 | <p> |
328 | <p> |
| 353 | Some compilers don't support all possible -target and -source arguments. |
329 | Some compilers don't support all possible -target and -source arguments. |
| 354 | Therefore, each compiler in the list is checked to see if it can support the |
330 | Therefore, each compiler in the list is checked to see if it can support the |
| … | |
… | |
| 386 | 1.5 syntax yet. |
362 | 1.5 syntax yet. |
| 387 | </ti> |
363 | </ti> |
| 388 | </tr> |
364 | </tr> |
| 389 | <tr> |
365 | <tr> |
| 390 | <ti>Eclipse Compiler for Java</ti> |
366 | <ti>Eclipse Compiler for Java</ti> |
| 391 | <ti>ecj-3.1</ti> |
367 | <ti>ecj</ti> |
| 392 | <ti>=dev-java/eclipse-ecj-3.1*</ti> |
368 | <ti>dev-java/eclipse-ecj</ti> |
| 393 | <ti> |
369 | <ti> |
| 394 | ECJ is the compiler used by the Eclipse software development kit. It is |
370 | ECJ is the compiler used by the Eclipse software development kit. It is |
| 395 | very full featured, and is pretty fast. It does support Java 1.5 syntax. |
371 | very full featured, and is pretty fast. It does support Java 1.5 syntax. |
| 396 | </ti> |
372 | </ti> |
| 397 | </tr> |
373 | </tr> |
| … | |
… | |
| 504 | </p> |
480 | </p> |
| 505 | |
481 | |
| 506 | <pre caption="Viewing available plugins"> |
482 | <pre caption="Viewing available plugins"> |
| 507 | # <i>eselect java-nsplugin list</i> |
483 | # <i>eselect java-nsplugin list</i> |
| 508 | [1] sun-jre-bin-1.6 |
484 | [1] sun-jre-bin-1.6 |
| 509 | [2] icedtea6-bin |
485 | [2] icedtea-bin |
| 510 | </pre> |
486 | </pre> |
| 511 | |
487 | |
| 512 | <p> |
488 | <p> |
| 513 | In this example, <c>sun-jre-bin</c> is selected for the browser plugin. |
489 | In this example, <c>sun-jre-bin</c> is selected for the browser plugin. |
| 514 | </p> |
490 | </p> |
| … | |
… | |
| 522 | </p> |
498 | </p> |
| 523 | |
499 | |
| 524 | <pre caption="Verifying the correct plugin"> |
500 | <pre caption="Verifying the correct plugin"> |
| 525 | # <i>eselect java-nsplugin list</i> |
501 | # <i>eselect java-nsplugin list</i> |
| 526 | [1] sun-jre-bin-1.6 current |
502 | [1] sun-jre-bin-1.6 current |
| 527 | [2] icedtea6-bin |
503 | [2] icedtea-bin |
| 528 | </pre> |
504 | </pre> |
| 529 | |
505 | |
| 530 | <p> |
506 | <p> |
| 531 | Java.com also provides a link to <uri |
507 | Java.com also provides a link to <uri |
| 532 | link="http://java.com/en/download/installed.jsp">verify your installed |
508 | link="http://java.com/en/download/installed.jsp">verify your installed |
| … | |
… | |
| 576 | # <i>eselect java-nsplugin list</i> |
552 | # <i>eselect java-nsplugin list</i> |
| 577 | Available 32-bit Java browser plugins |
553 | Available 32-bit Java browser plugins |
| 578 | [1] emul-linux-x86-java-1.5 |
554 | [1] emul-linux-x86-java-1.5 |
| 579 | [2] emul-linux-x86-java-1.6 |
555 | [2] emul-linux-x86-java-1.6 |
| 580 | Available 64-bit Java browser plugins |
556 | Available 64-bit Java browser plugins |
| 581 | [1] icedtea6-bin |
557 | [1] icedtea-bin |
| 582 | [2] sun-jre-bin-1.6 |
558 | [2] sun-jre-bin-1.6 |
| 583 | </pre> |
559 | </pre> |
| 584 | |
560 | |
| 585 | <p> |
561 | <p> |
| 586 | Now select the right plugin for your browsers: |
562 | Now select the right plugin for your browsers: |
| … | |
… | |
| 600 | # <i>eselect java-nsplugin list</i> |
576 | # <i>eselect java-nsplugin list</i> |
| 601 | Available 32-bit Java browser plugins |
577 | Available 32-bit Java browser plugins |
| 602 | [1] emul-linux-x86-java-1.5 |
578 | [1] emul-linux-x86-java-1.5 |
| 603 | [2] emul-linux-x86-java-1.6 current |
579 | [2] emul-linux-x86-java-1.6 current |
| 604 | Available 64-bit Java browser plugins |
580 | Available 64-bit Java browser plugins |
| 605 | [1] icedtea6-bin |
581 | [1] icedtea-bin |
| 606 | [2] sun-jre-bin-1.6 current |
582 | [2] sun-jre-bin-1.6 current |
| 607 | </pre> |
583 | </pre> |
| 608 | |
584 | |
| 609 | </body> |
585 | </body> |
| 610 | </section> |
586 | </section> |