/[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.27 Revision 1.44
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.27 2006/07/25 08:13:47 rane Exp $ --> 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"> 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"> 8<author title="Author">
9 <mail link="karltk@gentoo.org">Karl Trygve Kalleberg</mail> 9 <mail link="nichoj@gentoo.org">Joshua Nichols</mail>
10</author> 10</author>
11<author title="Author"> 11<author title="Author">
12 <mail link="nichoj@gentoo.org">Joshua Nichols</mail> 12 <mail link="karltk@gentoo.org">Karl Trygve Kalleberg</mail>
13</author> 13</author>
14<author title="Editor"> 14<author title="Editor">
15 <mail link="nightmorph@gentoo.org">Joshua Saddler</mail> 15 <mail link="nightmorph@gentoo.org">Joshua Saddler</mail>
16</author> 16</author>
17 17
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.5</version> 27<version>0.19</version>
28<date>2006-07-24</date> 28<date>2009-10-07</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>
45</p> 45</p>
46 46
47<p> 47<p>
48In order to run Java bytecode, one needs to have a JRE (Java Runtime 48In order to run Java bytecode, one needs to have a JRE (Java Runtime
49Environment) installed. A JRE provides core libraries, a platform dependent 49Environment) installed. A JRE provides core libraries, a platform dependent
50Java Virtual Machine, plug-ins for browsers, among other things. A JDK (Java 50Java Virtual Machine, plugins for browsers, among other things. A JDK (Java
51Development Kit) adds programming tools, such as a bytecode compiler and a 51Development Kit) adds programming tools, such as a bytecode compiler and a
52debugger. 52debugger.
53</p> 53</p>
54 54
55</body> 55</body>
56</section> 56</section>
57</chapter> 57</chapter>
58 58
59<chapter> 59<chapter>
60<title>Installing a JRE/JDK</title> 60<title>Before You Begin</title>
61<section>
62<title>Existing installs</title>
63<body>
64
65<p>
66For existing installs, regardless of if you have installed anything Java
67before, make sure you have followed the <uri
68link="/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>
78New 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>
61<section> 87<section>
62<title>The choices</title> 88<title>The choices</title>
63<body> 89<body>
64 90
65<p> 91<p>
66Gentoo provides numerous JREs and JDKs. Among the current alternatives, we 92Gentoo provides numerous Runtime Environments (JREs) and Development Kits
67have: 93(JDKs). Among the current choices, we have:
68</p> 94</p>
69 95
70<table> 96<table>
71<tr> 97<tr>
72 <th>Vendor</th> 98 <th>Vendor</th>
87 <ti>The IBM Java Kit</ti> 113 <ti>The IBM Java Kit</ti>
88 <ti>dev-java/ibm-jdk-bin</ti> 114 <ti>dev-java/ibm-jdk-bin</ti>
89 <ti>dev-java/ibm-jre-bin</ti> 115 <ti>dev-java/ibm-jre-bin</ti>
90</tr> 116</tr>
91<tr> 117<tr>
92 <ti>The Compaq Java Kit for Alpha/Linux/GNU</ti>
93 <ti>dev-java/compaq-jdk</ti>
94 <ti>dev-java/compaq-jre</ti>
95</tr>
96<tr>
97 <ti>BEA WebLogic's J2SE Development Kit</ti> 118 <ti>BEA WebLogic's J2SE Development Kit</ti>
98 <ti>dev-java/jrockit-jdk-bin</ti> 119 <ti>dev-java/jrockit-jdk-bin</ti>
99</tr> 120</tr>
100</table> 121</table>
101 122
102<!-- 123<!--
103TODO: list free implementations? 124TODO: list free implementations?
104note about not drop-in replacements 125note about not drop-in replacements
105kaffe/sablevm/gcj/jamvm 126kaffe/sablevm/gcj/jamvm
106--> 127-->
107
108<p>
109The default is Blackdown for both the JRE and the JDK, as it is freely ("free
110as in beer") available without any registration fuss.
111</p> 128<p>
112 129The default for Java 1.6 is the Sun JRE/JDK pair.
113<p>
114Both the Sun and the IBM are generally faster, but getting them is a bit more
115hassle, as you are required to read and accept their license before downloading
116(IBM additionally requires you to register).
117</p>
118
119<p>
120Our ebuilds for the Sun and IBM JRE/JDKs will inform you how to download the
121appropriate files.
122</p> 130</p>
123 131
124</body> 132</body>
125</section> 133</section>
126<section> 134<section>
128<body> 136<body>
129 137
130<p> 138<p>
131To install your profile's default JDK, you can run <c>emerge virtual/jdk</c>. 139To install your profile's default JDK, you can run <c>emerge virtual/jdk</c>.
132Or to install your profile's default JRE, you can <c>emerge virtual/jre</c>. 140Or to install your profile's default JRE, you can <c>emerge virtual/jre</c>.
141</p>
142
143<p>
144In recent events, Sun has relicensed their JDK and JRE under a more Linux
145distro friendly license. As a result, Sun releases Java 1.5 and onwards are
146freely downloadable, without any further hassle.
133</p> 147</p>
134 148
135<note> 149<note>
136A JDK also includes a JRE, so if you install a JDK you shouldn't have to also 150A JDK also includes a JRE, so if you install a JDK you shouldn't have to also
137have to install a JRE. 151have to install a JRE.
138</note> 152</note>
139 153
140</body> 154</body>
141</section> 155</section>
142<section> 156<section>
143<title>Installing the Sun/IBM JRE/JDKs</title> 157<title>Installing fetch-restricted virtual machines</title>
144<body> 158<body>
145 159
146<p> 160<p>
147If you run <c>emerge dev-java/sun-jdk</c> or <c>emerge 161Some of the JDKs and JREs require you to jump through a few hoops before
148dev-java/ibm-jdk-bin</c>, you will be notified that you are required to 162installing. Simply emerge the packages as you normally would. The ebuilds will
149download the actual files yourself. This has to do with license restrictions 163then instruct you where to go and what to download.
150for the Sun JRE/JDK (online click-wrap license) and registration issues with
151the IBM JRE/JDK.
152</p> 164</p>
153 165
154<p> 166<p>
155You should download the indicated file(s) into 167You should download the indicated file(s) into
156<path>/usr/portage/distfiles</path>. Once there, you can rerun the emerge 168<path>/usr/portage/distfiles</path>. Once there, you can rerun the emerge
160</body> 172</body>
161</section> 173</section>
162</chapter> 174</chapter>
163 175
164<chapter> 176<chapter>
165<title>Configuring your JRE/JDK</title> 177<title>Configuring your virtual machine</title>
166<section> 178<section>
167<title>Overview</title> 179<title>Overview</title>
168<body> 180<body>
169 181
170<p> 182<p>
184</note> 196</note>
185 197
186</body> 198</body>
187</section> 199</section>
188<section> 200<section>
189<title>Setting a default JRE/JDK</title> 201<title>Setting a default virtual machine</title>
190<body> 202<body>
191 203
192<p> 204<p>
193Running the command <c>java-config --list-available-vms</c> will give you a 205Running the command <c>java-config --list-available-vms</c> will give you a
194list of all JREs and JDKs installed on your system. Here is an example of 206list of all JREs and JDKs installed on your system. Here is an example of
195output: 207output:
196</p> 208</p>
197 209
198<pre caption="Listing available VMs"> 210<pre caption="Listing available VMs">
199# <i>java-config --list-available-vms</i> 211# <i>java-config --list-available-vms</i>
2001) Blackdown JDK 1.3.1 [blackdown-jdk-1.3] (/etc/env.d/java/20blackdown-jdk-1.3) 212The following VMs are available for generation-2:
2012) Blackdown JDK 1.4.2.02 [blackdown-jdk-1.4] (/etc/env.d/java/20blackdown-jdk-1.4) 2131) Blackdown JDK 1.4.2.03 [blackdown-jdk-1.4.2] <comment>(Build Only)</comment>
2023) Blackdown JRE 1.4.2.02 [blackdown-jre-1.4] (/etc/env.d/java/20blackdown-jre-1.4) 2142) Blackdown JRE 1.4.2.03 [blackdown-jre-1.4.2] <comment>(Build Only)</comment>
2034) IBM JDK 1.4.2 [ibm-jdk-bin-1.4] (/etc/env.d/java/20ibm-jdk-bin-1.4) 2153) IcedTea6-bin 1.4.1 [icedtea6-bin]
2045) IBM JRE 1.4.2 [ibm-jre-bin-1.4] (/etc/env.d/java/20ibm-jre-bin-1.4) 2164) Sun JDK 1.5.0.20 [sun-jdk-1.5] <comment>(Build Only)</comment>
2056) WebLogic JRockit 1.4.2.05 [jrockit-jdk-bin-1.4] (/etc/env.d/java/20jrockit-jdk-bin-1.4) 217*) Sun JDK 1.6.0.16 [sun-jdk-1.6]
2067) WebLogic JRockit 1.5.0.03 [jrockit-jdk-bin-1.5] (/etc/env.d/java/20jrockit-jdk-bin-1.5)
2078) Sun JDK 1.3.1.13 [sun-jdk-1.3] (/etc/env.d/java/20sun-jdk-1.3)
2089) Sun JDK 1.4.2.09 [sun-jdk-1.4] (/etc/env.d/java/20sun-jdk-1.4)
209*) Sun JDK 1.5.0.04 [sun-jdk-1.5] (/etc/env.d/java/20sun-jdk-1.5)
21011) Sun JRE 1.4.2.09 [sun-jre-bin-1.4] (/etc/env.d/java/20sun-jre-bin-1.4)
21112) Sun JRE 1.5.0.04 [sun-jre-bin-1.5] (/etc/env.d/java/20sun-jre-bin-1.5)
212</pre> 218</pre>
219
220<note>
221VMs marked as Build Only may contain security vulnerabilities and/or be EOL.
222Gentoo recommends not setting these VMs as either your system or user VM.
223Please see <uri link="java.xml#build-only">Build Only VM</uri> for more
224information.
225</note>
213 226
214<p> 227<p>
215The <e>*</e> indicates this is the current active vm (system-vm or user-vm when 228The <e>*</e> indicates this is the current active vm (system-vm or user-vm when
216set). The name in the brackets (<e>[]</e>) is the handle or ID for that 229set). The name in the brackets (<e>[]</e>) is the handle or ID for that
217particular VM. You use the handle or the number to <c>java-config 230particular VM. You use the handle or the number to <c>java-config
219</p> 232</p>
220 233
221<pre caption="Setting the System VM"> 234<pre caption="Setting the System VM">
222<comment>(By handle (preferred))</comment> 235<comment>(By handle (preferred))</comment>
223# <i>java-config --set-system-vm blackdown-jdk-1.4</i> 236# <i>java-config --set-system-vm blackdown-jdk-1.4</i>
237Now using blackdown-jdk-1.4 as your generation-2 system JVM
238WARNING: blackdown-jdk-1.4 is marked as a build-only JVM. Using this vm is not recommended.
224<comment>(By number)</comment> 239<comment>(By number)</comment>
225# <i>java-config --set-system-vm 2</i> 240# <i>java-config --set-system-vm 5</i>
241Now using sun-jdk-1.6 as your generation-2 system JVM
226</pre> 242</pre>
227 243
228<p> 244<p>
229As a regular user, you can use <c>java-config --set-user-vm</c>. 245As a regular user, you can use <c>java-config --set-user-vm</c>.
230</p> 246</p>
234VM take place. 250VM take place.
235</note> 251</note>
236 252
237</body> 253</body>
238</section> 254</section>
255<section id="build-only">
256<title>Build Only VM</title>
257<body>
258
259<p>
260Some virtual machines are flagged as build-only due to being EOL and/or
261containing security vulnerabilities. These virtual machines will not
262automatically be used by Gentoo for the running of applications using Gentoo
263launchers but will still be available for use by Gentoo's build environment as
264some packages may require them for building. The setting of these virtual
265machines as either your system or user VM is strongly discouraged as these VMs
266will then be used when running the <path>/usr/bin/{java,javac,..}</path>
267executables and will also be used by any packages not using Gentoo's launcher
268scripts.
269</p>
270
271</body>
272</section>
239<section id="preferred-vm"> 273<section id="preferred-vm">
240<title>Preferred VM</title> 274<title>Preferred VM</title>
241<body> 275<body>
242 276
243<p> 277<p>
247<p> 281<p>
248Because of the wide variety of available VMs, we do not have the resources to 282Because of the wide variety of available VMs, we do not have the resources to
249test and verify every package works on all of them. So to ensure that every 283test and verify every package works on all of them. So to ensure that every
250packages merges smoothly, we have defined a list of <e>default/supported 284packages merges smoothly, we have defined a list of <e>default/supported
251VMs</e> per arch. You can find them in 285VMs</e> per arch. You can find them in
252<path>/usr/share/java-config/config/jdk-defaults.conf</path>. When you are 286<path>/usr/share/java-config-2/config/jdk-defaults.conf</path>. When you are
253merging a Java package, and it detects one of the VM in that file is installed, 287merging a Java package, and it detects one of the VM in that file is installed,
254it will automatically use that VM, instead of the system-vm. 288it will automatically use that VM, instead of the system-vm.
255</p> 289</p>
256 290
257<p> 291<p>
421</p> 455</p>
422 456
423<p> 457<p>
424For users, <c>java-config --set-user-classpath</c> will create 458For users, <c>java-config --set-user-classpath</c> will create
425<path>~/.gentoo/java-env-classpath</path>, which you should then source from 459<path>~/.gentoo/java-env-classpath</path>, which you should then source from
426your shell's profile. 460your shell's profile.
427</p> 461</p>
428 462
429<pre caption="Sourcing user specific classpath"> 463<pre caption="Sourcing user specific classpath">
430<i>if [[ -f "${HOME}/.gentoo/java-env-classpath" ]]; then 464<i>if [[ -f "${HOME}/.gentoo/java-env-classpath" ]]; then
431 source ${HOME}/.gentoo/java-env-classpath 465 source ${HOME}/.gentoo/java-env-classpath
437something like the following to your shell's profile. But we would advise 471something like the following to your shell's profile. But we would advise
438against it. 472against it.
439</p> 473</p>
440 474
441<pre caption="Setting classpath"> 475<pre caption="Setting classpath">
442# <i>export CLASSPATH="${CLASSPATH}:$(java-config --classpath log4j,xerces-2)"</i> 476# <i>export CLASSPATH="${CLASSPATH}:$(java-config --classpath log4j,xerces-2)"</i>
477</pre>
478
479</body>
480</section>
481</chapter>
482
483<chapter>
484<title>Java Browser Plugins</title>
485<section>
486<title>Installing a plugin</title>
487<body>
488
489<p>
490You can install a Java plugin for your web browser by emerging a Java VM with
491the <c>nsplugin</c> USE flag set.
492</p>
493
494<note>
495<c>nsplugin</c> is not available for all architectures. Check for available
496plugins on your arch before trying to install a VM by running <c>emerge -pv
497&lt;java-vm&gt;</c>.
498</note>
499
500<p>
501Portage will allow you to install multiple versions of Java plugins, though
502only one will be used by your browser. You can check the list of available
503plugins by running:
504</p>
505
506<pre caption="Viewing available plugins">
507# <i>eselect java-nsplugin list</i>
508 [1] sun-jre-bin-1.6
509 [2] icedtea6-bin
510</pre>
511
512<p>
513In this example, <c>sun-jre-bin</c> is selected for the browser plugin.
514</p>
515
516<pre caption="Selecting a plugin">
517# <i>eselect java-nsplugin set sun-jre-bin-1.6</i>
518</pre>
519
520<p>
521Verify that the correct plugin was selected:
522</p>
523
524<pre caption="Verifying the correct plugin">
525# <i>eselect java-nsplugin list</i>
526 [1] sun-jre-bin-1.6 current
527 [2] icedtea6-bin
528</pre>
529
530<p>
531Java.com also provides a link to <uri
532link="http://java.com/en/download/installed.jsp">verify your installed
533plugin</uri>. Additionally, if you are using a Mozilla-based browser, you can
534verify your Java plugin by typing <c>about:plugins</c> into the address bar.
535</p>
536
537</body>
538</section>
539<section>
540<title>Plugins on multilib systems</title>
541<body>
542
543<p>
544If you are running a mixed 64-bit and 32-bit multilib system (for example, on
545AMD64), you can use 64-bit and 32-bit Java plugins. Unless you have a pressing
546need to run 32-bit Java applications, we recommend using native 64-bit plugins
547on 64-bit web browsers.
548</p>
549
550<p>
551There are several native 64-bit browser plugins available. The default JDK/JRE
552pair, <c>sun-jdk</c> and <c>sun-jre-bin</c>, both include browser plugins. Just
553emerge one of them with the <c>nsplugin</c> USE flag enabled.
554</p>
555
556<pre caption="Installing a 64-bit plugin">
557# <i>echo "dev-java/sun-jre-bin nsplugin" >> /etc/portage/package.use</i>
558# <i>emerge sun-jre-bin</i>
559</pre>
560
561<p>
562To use a 32-bit plugin on a 32-bit browser, you will need to emerge
563<c>emul-linux-x86-java</c> with the <c>nsplugin</c> USE flag enabled.
564</p>
565
566<pre caption="Installing a 32-bit plugin">
567# <i>echo "app-emulation/emul-linux-x86-java nsplugin" >> /etc/portage/package.use</i>
568# <i>emerge emul-linux-x86-java</i>
569</pre>
570
571<p>
572Next, check which plugins are available:
573</p>
574
575<pre caption="Viewing available plugins">
576# <i>eselect java-nsplugin list</i>
577Available 32-bit Java browser plugins
578 [1] emul-linux-x86-java-1.5
579 [2] emul-linux-x86-java-1.6
580Available 64-bit Java browser plugins
581 [1] icedtea6-bin
582 [2] sun-jre-bin-1.6
583</pre>
584
585<p>
586Now select the right plugin for your browsers:
587</p>
588
589<pre caption="Selecting plugins">
590<comment>(Choose the plugins for 32-bit and 64-bit browsers)</comment>
591# <i>eselect java-nsplugin set 32bit emul-linux-x86-java-1.6</i>
592# <i>eselect java-nsplugin set 64bit sun-jre-bin-1.6</i>
593</pre>
594
595<p>
596Verify the correct plugin was selected:
597</p>
598
599<pre caption="Verifying the correct plugin">
600# <i>eselect java-nsplugin list</i>
601Available 32-bit Java browser plugins
602 [1] emul-linux-x86-java-1.5
603 [2] emul-linux-x86-java-1.6 current
604Available 64-bit Java browser plugins
605 [1] icedtea6-bin
606 [2] sun-jre-bin-1.6 current
443</pre> 607</pre>
444 608
445</body> 609</body>
446</section> 610</section>
447</chapter> 611</chapter>
466 630
467<ul> 631<ul>
468 <li>The <b>java</b> flag adds support for Java in a variety of programs</li> 632 <li>The <b>java</b> flag adds support for Java in a variety of programs</li>
469 <li> 633 <li>
470 The <b>nsplugin</b> flag adds support for Mozilla-like browsers (including 634 The <b>nsplugin</b> flag adds support for Mozilla-like browsers (including
471 Firefox).You will need this for viewing Java applets in your Mozilla-like 635 Firefox). You will need this for viewing Java applets in your Mozilla-like
472 browser. 636 browser.
473 </li> 637 </li>
474 <li> 638 <li>
475 The <b>doc</b> flag will typically install API documentation, as generated 639 The <b>source</b> flag installs a zip of the source code of a package.
476 by javadoc. 640 This is traditionally used for IDEs to 'attach' source to the libraries you
641 are using.
477 </li> 642 </li>
643 <li>The <b>jce</b> flag adds support for the Java Cryptography Engine</li>
478 <li> 644 <li>
479 The <b>source</b> flag will install a zip of the package's source code. 645 For Java packages, the <b>doc</b> flag will build API documentation using
480 This is typically used to provide your IDE with the source code for the 646 javadoc.
481 package.
482 </li> 647 </li>
483</ul> 648</ul>
484 649
485</body> 650</body>
486</section> 651</section>
515 link="http://news.gmane.org/gmane.linux.gentoo.user">gentoo-user</uri>, and 680 link="http://news.gmane.org/gmane.linux.gentoo.user">gentoo-user</uri>, and
516 <uri 681 <uri
517 link="http://news.gmane.org/gmane.linux.gentoo.devel">gentoo-dev</uri> 682 link="http://news.gmane.org/gmane.linux.gentoo.devel">gentoo-dev</uri>
518 mailing list archives 683 mailing list archives
519 </li> 684 </li>
520 <li>#gentoo and #gentoo-java on irc.freenode.net</li> 685 <li>
686 <uri link="irc://irc.gentoo.org/gentoo">#gentoo</uri> and <uri
687 link="irc://irc.gentoo.org/gentoo-java">#gentoo-java</uri> on IRC
688 </li>
521 <li> 689 <li>
522 <uri 690 <uri
523 link="http://en.wikipedia.org/wiki/Java_programming_language">Wikipedia's 691 link="http://en.wikipedia.org/wiki/Java_programming_language">Wikipedia's
524 entry for Java</uri> 692 entry for Java</uri>
525 </li> 693 </li>
694 <li>
695 If you have suggestions or questions regarding this document, please email
696 the Gentoo Java team: <mail>java@gentoo.org</mail>
697 </li>
526</ul> 698</ul>
527 699
528</body> 700</body>
529</section> 701</section>
530</chapter> 702</chapter>

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.44

  ViewVC Help
Powered by ViewVC 1.1.20