/[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.29 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.29 2006/08/09 20:44:33 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
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.7</version> 27<version>0.19</version>
28<date>2006-08-08</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>New Java System</title> 60<title>Before You Begin</title>
61<section>
62<body>
63
64<p>
65The way Java is handled on Gentoo has recently seen many changes and
66improvements. This has only happened very recently, and as a result, all the
67packages related to it are marked with testing keywords, ie ~x86. This
68document assumes you are using the new system.
69</p>
70
71</body>
72</section>
73<section>
74<title>Keywords</title>
75<body>
76
77<p>
78If you are using the stable tree, i.e. x86, ppc, or amd64 as opposed to ~x86,
79~ppc, or ~amd64, you will need to add some entries to your
80<path>/etc/portage/package.keywords</path>:
81</p>
82
83<pre caption="package.keywords">
84# Core Gentoo/Java Packages
85dev-java/ant-core
86dev-java/ant-tasks
87dev-java/ant
88dev-java/java-config
89dev-java/java-config-wrapper
90dev-java/javatoolkit
91dev-java/sun-jce-bin
92# JDKs
93=dev-java/sun-jdk-1.4*
94=dev-java/sun-jdk-1.5*
95=dev-java/ibm-jdk-bin-1.4*
96=dev-java/ibm-jdk-bin-1.5*
97=dev-java/jrockit-jdk-bin-1.4*
98=dev-java/jrockit-jdk-bin-1.5*
99=dev-java/blackdown-jdk-1.4*
100dev-java/kaffe
101# JREs
102=dev-java/sun-jre-bin-1.4*
103=dev-java/sun-jre-bin-1.5*
104=dev-java/ibm-jre-bin-1.4*
105=dev-java/blackdown-jre-1.4*
106# Virtuals
107virtual/jdk
108virtual/jre
109# Compilers
110dev-java/eclipse-ecj
111dev-java/jikes
112# Documentation
113dev-java/java-sdk-docs
114# Misc packages that have been updated to generation-2,
115# where the generation-1 won't build and/or run properly
116dev-java/lucene
117# These have optional Java support, but need ~arch to function properly
118# with generation-2
119dev-util/subversion
120sys-libs/db
121</pre>
122
123<impo>
124It is crucial that you keyword ALL packages related to the new Java system,
125otherwise you will have problems in the later steps of this guide.
126</impo>
127
128<impo>
129It can't be emphasized enough that you have to have ALL the packages related
130to the new Java system keyworded for it to function properly.
131</impo>
132
133</body>
134</section>
135<section> 61<section>
136<title>Existing installs</title> 62<title>Existing installs</title>
137<body> 63<body>
138 64
139<p> 65<p>
187 <ti>The IBM Java Kit</ti> 113 <ti>The IBM Java Kit</ti>
188 <ti>dev-java/ibm-jdk-bin</ti> 114 <ti>dev-java/ibm-jdk-bin</ti>
189 <ti>dev-java/ibm-jre-bin</ti> 115 <ti>dev-java/ibm-jre-bin</ti>
190</tr> 116</tr>
191<tr> 117<tr>
192 <ti>The Compaq Java Kit for Alpha/Linux/GNU</ti>
193 <ti>dev-java/compaq-jdk</ti>
194 <ti>dev-java/compaq-jre</ti>
195</tr>
196<tr>
197 <ti>BEA WebLogic's J2SE Development Kit</ti> 118 <ti>BEA WebLogic's J2SE Development Kit</ti>
198 <ti>dev-java/jrockit-jdk-bin</ti> 119 <ti>dev-java/jrockit-jdk-bin</ti>
199</tr> 120</tr>
200</table> 121</table>
201 122
202<!-- 123<!--
203TODO: list free implementations? 124TODO: list free implementations?
204note about not drop-in replacements 125note about not drop-in replacements
205kaffe/sablevm/gcj/jamvm 126kaffe/sablevm/gcj/jamvm
206--> 127-->
207
208<p>
209The default is Blackdown for both the JRE and the JDK, as it is freely ("free
210as in beer") available without any registration fuss.
211</p> 128<p>
212 129The default for Java 1.6 is the Sun JRE/JDK pair.
213<p>
214The default for Java 1.4 is the Blackdown JRE/JDK pair, as it is freely
215("free as in beer") available without any registration fuss.
216</p>
217
218<p>
219JREs and JDKs from Sun, IBM, and BEA are generally faster, but getting them
220is a bit more work, as you are required to read and accept their license before
221downloading (IBM additionally requires you to register).
222</p> 130</p>
223 131
224</body> 132</body>
225</section> 133</section>
226<section> 134<section>
248<section> 156<section>
249<title>Installing fetch-restricted virtual machines</title> 157<title>Installing fetch-restricted virtual machines</title>
250<body> 158<body>
251 159
252<p> 160<p>
253As already mentioned, some of the JDKs and JREs require you to jump through a 161Some of the JDKs and JREs require you to jump through a few hoops before
254few hoops before installing. Simply emerge the packages as you normally would. 162installing. Simply emerge the packages as you normally would. The ebuilds will
255The ebuilds will then instruct you where to go and what to download. 163then instruct you where to go and what to download.
256</p> 164</p>
257 165
258<p> 166<p>
259You should download the indicated file(s) into 167You should download the indicated file(s) into
260<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
299output: 207output:
300</p> 208</p>
301 209
302<pre caption="Listing available VMs"> 210<pre caption="Listing available VMs">
303# <i>java-config --list-available-vms</i> 211# <i>java-config --list-available-vms</i>
3041) 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:
3052) 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>
3063) 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>
3074) 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]
3085) 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>
3096) 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]
3107) WebLogic JRockit 1.5.0.03 [jrockit-jdk-bin-1.5] (/etc/env.d/java/20jrockit-jdk-bin-1.5)
3118) Sun JDK 1.3.1.13 [sun-jdk-1.3] (/etc/env.d/java/20sun-jdk-1.3)
3129) Sun JDK 1.4.2.09 [sun-jdk-1.4] (/etc/env.d/java/20sun-jdk-1.4)
313*) Sun JDK 1.5.0.04 [sun-jdk-1.5] (/etc/env.d/java/20sun-jdk-1.5)
31411) Sun JRE 1.4.2.09 [sun-jre-bin-1.4] (/etc/env.d/java/20sun-jre-bin-1.4)
31512) Sun JRE 1.5.0.04 [sun-jre-bin-1.5] (/etc/env.d/java/20sun-jre-bin-1.5)
316</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>
317 226
318<p> 227<p>
319The <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
320set). 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
321particular 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
323</p> 232</p>
324 233
325<pre caption="Setting the System VM"> 234<pre caption="Setting the System VM">
326<comment>(By handle (preferred))</comment> 235<comment>(By handle (preferred))</comment>
327# <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.
328<comment>(By number)</comment> 239<comment>(By number)</comment>
329# <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
330</pre> 242</pre>
331 243
332<p> 244<p>
333As 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>.
334</p> 246</p>
338VM take place. 250VM take place.
339</note> 251</note>
340 252
341</body> 253</body>
342</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>
343<section id="preferred-vm"> 273<section id="preferred-vm">
344<title>Preferred VM</title> 274<title>Preferred VM</title>
345<body> 275<body>
346 276
347<p> 277<p>
351<p> 281<p>
352Because 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
353test 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
354packages merges smoothly, we have defined a list of <e>default/supported 284packages merges smoothly, we have defined a list of <e>default/supported
355VMs</e> per arch. You can find them in 285VMs</e> per arch. You can find them in
356<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
357merging 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,
358it will automatically use that VM, instead of the system-vm. 288it will automatically use that VM, instead of the system-vm.
359</p> 289</p>
360 290
361<p> 291<p>
525</p> 455</p>
526 456
527<p> 457<p>
528For users, <c>java-config --set-user-classpath</c> will create 458For users, <c>java-config --set-user-classpath</c> will create
529<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
530your shell's profile. 460your shell's profile.
531</p> 461</p>
532 462
533<pre caption="Sourcing user specific classpath"> 463<pre caption="Sourcing user specific classpath">
534<i>if [[ -f "${HOME}/.gentoo/java-env-classpath" ]]; then 464<i>if [[ -f "${HOME}/.gentoo/java-env-classpath" ]]; then
535 source ${HOME}/.gentoo/java-env-classpath 465 source ${HOME}/.gentoo/java-env-classpath
541something 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
542against it. 472against it.
543</p> 473</p>
544 474
545<pre caption="Setting classpath"> 475<pre caption="Setting classpath">
546# <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
547</pre> 607</pre>
548 608
549</body> 609</body>
550</section> 610</section>
551</chapter> 611</chapter>
570 630
571<ul> 631<ul>
572 <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>
573 <li> 633 <li>
574 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
575 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
576 browser. 636 browser.
577 </li> 637 </li>
578 <li> 638 <li>
579 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.
580 by javadoc. 640 This is traditionally used for IDEs to 'attach' source to the libraries you
641 are using.
581 </li> 642 </li>
582 <li> 643 <li>The <b>jce</b> flag adds support for the Java Cryptography Engine</li>
583 The <b>source</b> flag will install a zip of the package's source code.
584 This is typically used to provide your IDE with the source code for the
585 package.
586 </li>
587 <li>
588 The <b>source</b> flag installs a zip of the source code of a package.
589 This is traditionally used for for IDEs to 'attach' source to the libraries
590 you are using.
591 </li>
592 <li> 644 <li>
593 For Java packages, the <b>doc</b> flag will build API documentation using 645 For Java packages, the <b>doc</b> flag will build API documentation using
594 javadoc. 646 javadoc.
595 </li> 647 </li>
596</ul> 648</ul>
628 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
629 <uri 681 <uri
630 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>
631 mailing list archives 683 mailing list archives
632 </li> 684 </li>
633 <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>
634 <li> 689 <li>
635 <uri 690 <uri
636 link="http://en.wikipedia.org/wiki/Java_programming_language">Wikipedia's 691 link="http://en.wikipedia.org/wiki/Java_programming_language">Wikipedia's
637 entry for Java</uri> 692 entry for Java</uri>
638 </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>
639</ul> 698</ul>
640 699
641</body> 700</body>
642</section> 701</section>
643</chapter> 702</chapter>

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

  ViewVC Help
Powered by ViewVC 1.1.20