/[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.32 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.32 2006/09/10 21:30:58 nightmorph 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.9</version> 27<version>0.19</version>
28<date>2006-09-10</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 opposed to ~arch, you will need to add some
79entries to your <path>/etc/portage/package.keywords</path>:
80</p>
81
82<pre caption="package.keywords">
83# Core Gentoo/Java Packages
84dev-java/ant-core
85dev-java/ant-tasks
86dev-java/ant
87dev-java/java-config
88dev-java/java-config-wrapper
89dev-java/javatoolkit
90dev-java/sun-jce-bin
91# JDKs
92=dev-java/sun-jdk-1.4*
93=dev-java/sun-jdk-1.5*
94=dev-java/ibm-jdk-bin-1.4*
95=dev-java/ibm-jdk-bin-1.5*
96=dev-java/jrockit-jdk-bin-1.4*
97=dev-java/jrockit-jdk-bin-1.5*
98=dev-java/blackdown-jdk-1.4*
99dev-java/kaffe
100# JREs
101=dev-java/sun-jre-bin-1.4*
102=dev-java/sun-jre-bin-1.5*
103=dev-java/ibm-jre-bin-1.4*
104=dev-java/blackdown-jre-1.4*
105# Virtuals
106virtual/jdk
107virtual/jre
108# Compilers
109dev-java/eclipse-ecj
110dev-java/jikes
111# Documentation
112dev-java/java-sdk-docs
113# Misc packages that have been updated to generation-2,
114# where the generation-1 won't build and/or run properly
115dev-java/lucene
116# These have optional Java support, but need ~arch to function properly
117# with generation-2
118dev-util/subversion
119sys-libs/db
120</pre>
121
122<warn>
123It is crucial that you list ALL these packages in
124<path>/etc/portage/package.keywords</path>, otherwise you will have problems in
125the later steps of this guide. Your new Java system will not function correctly
126without this list.
127</warn>
128
129</body>
130</section>
131<section> 61<section>
132<title>Existing installs</title> 62<title>Existing installs</title>
133<body> 63<body>
134 64
135<p> 65<p>
183 <ti>The IBM Java Kit</ti> 113 <ti>The IBM Java Kit</ti>
184 <ti>dev-java/ibm-jdk-bin</ti> 114 <ti>dev-java/ibm-jdk-bin</ti>
185 <ti>dev-java/ibm-jre-bin</ti> 115 <ti>dev-java/ibm-jre-bin</ti>
186</tr> 116</tr>
187<tr> 117<tr>
188 <ti>The Compaq Java Kit for Alpha/Linux/GNU</ti>
189 <ti>dev-java/compaq-jdk</ti>
190 <ti>dev-java/compaq-jre</ti>
191</tr>
192<tr>
193 <ti>BEA WebLogic's J2SE Development Kit</ti> 118 <ti>BEA WebLogic's J2SE Development Kit</ti>
194 <ti>dev-java/jrockit-jdk-bin</ti> 119 <ti>dev-java/jrockit-jdk-bin</ti>
195</tr> 120</tr>
196</table> 121</table>
197 122
198<!-- 123<!--
199TODO: list free implementations? 124TODO: list free implementations?
200note about not drop-in replacements 125note about not drop-in replacements
201kaffe/sablevm/gcj/jamvm 126kaffe/sablevm/gcj/jamvm
202--> 127-->
203<p> 128<p>
204The default for Java 1.4 is the Blackdown JRE/JDK pair, as it is freely 129The default for Java 1.6 is the Sun JRE/JDK pair.
205("free as in beer") available without any registration fuss.
206</p>
207
208<p>
209JREs and JDKs from Sun, IBM, and BEA are generally faster, but getting them
210is a bit more work, as you are required to read and accept their license before
211downloading (IBM additionally requires you to register).
212</p> 130</p>
213 131
214</body> 132</body>
215</section> 133</section>
216<section> 134<section>
238<section> 156<section>
239<title>Installing fetch-restricted virtual machines</title> 157<title>Installing fetch-restricted virtual machines</title>
240<body> 158<body>
241 159
242<p> 160<p>
243As 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
244few hoops before installing. Simply emerge the packages as you normally would. 162installing. Simply emerge the packages as you normally would. The ebuilds will
245The ebuilds will then instruct you where to go and what to download. 163then instruct you where to go and what to download.
246</p> 164</p>
247 165
248<p> 166<p>
249You should download the indicated file(s) into 167You should download the indicated file(s) into
250<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
289output: 207output:
290</p> 208</p>
291 209
292<pre caption="Listing available VMs"> 210<pre caption="Listing available VMs">
293# <i>java-config --list-available-vms</i> 211# <i>java-config --list-available-vms</i>
2941) 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:
2952) 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>
2963) 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>
2974) 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]
2985) 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>
2996) 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]
3007) WebLogic JRockit 1.5.0.03 [jrockit-jdk-bin-1.5] (/etc/env.d/java/20jrockit-jdk-bin-1.5)
3018) Sun JDK 1.3.1.13 [sun-jdk-1.3] (/etc/env.d/java/20sun-jdk-1.3)
3029) Sun JDK 1.4.2.09 [sun-jdk-1.4] (/etc/env.d/java/20sun-jdk-1.4)
303*) Sun JDK 1.5.0.04 [sun-jdk-1.5] (/etc/env.d/java/20sun-jdk-1.5)
30411) Sun JRE 1.4.2.09 [sun-jre-bin-1.4] (/etc/env.d/java/20sun-jre-bin-1.4)
30512) Sun JRE 1.5.0.04 [sun-jre-bin-1.5] (/etc/env.d/java/20sun-jre-bin-1.5)
306</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>
307 226
308<p> 227<p>
309The <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
310set). 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
311particular 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
313</p> 232</p>
314 233
315<pre caption="Setting the System VM"> 234<pre caption="Setting the System VM">
316<comment>(By handle (preferred))</comment> 235<comment>(By handle (preferred))</comment>
317# <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.
318<comment>(By number)</comment> 239<comment>(By number)</comment>
319# <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
320</pre> 242</pre>
321 243
322<p> 244<p>
323As 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>.
324</p> 246</p>
328VM take place. 250VM take place.
329</note> 251</note>
330 252
331</body> 253</body>
332</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>
333<section id="preferred-vm"> 273<section id="preferred-vm">
334<title>Preferred VM</title> 274<title>Preferred VM</title>
335<body> 275<body>
336 276
337<p> 277<p>
341<p> 281<p>
342Because 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
343test 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
344packages merges smoothly, we have defined a list of <e>default/supported 284packages merges smoothly, we have defined a list of <e>default/supported
345VMs</e> per arch. You can find them in 285VMs</e> per arch. You can find them in
346<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
347merging 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,
348it will automatically use that VM, instead of the system-vm. 288it will automatically use that VM, instead of the system-vm.
349</p> 289</p>
350 290
351<p> 291<p>
515</p> 455</p>
516 456
517<p> 457<p>
518For users, <c>java-config --set-user-classpath</c> will create 458For users, <c>java-config --set-user-classpath</c> will create
519<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
520your shell's profile. 460your shell's profile.
521</p> 461</p>
522 462
523<pre caption="Sourcing user specific classpath"> 463<pre caption="Sourcing user specific classpath">
524<i>if [[ -f "${HOME}/.gentoo/java-env-classpath" ]]; then 464<i>if [[ -f "${HOME}/.gentoo/java-env-classpath" ]]; then
525 source ${HOME}/.gentoo/java-env-classpath 465 source ${HOME}/.gentoo/java-env-classpath
531something 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
532against it. 472against it.
533</p> 473</p>
534 474
535<pre caption="Setting classpath"> 475<pre caption="Setting classpath">
536# <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
537</pre> 607</pre>
538 608
539</body> 609</body>
540</section> 610</section>
541</chapter> 611</chapter>
560 630
561<ul> 631<ul>
562 <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>
563 <li> 633 <li>
564 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
565 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
566 browser. 636 browser.
567 </li> 637 </li>
568 <li> 638 <li>
569 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.
570 by javadoc. 640 This is traditionally used for IDEs to 'attach' source to the libraries you
641 are using.
571 </li> 642 </li>
572 <li> 643 <li>The <b>jce</b> flag adds support for the Java Cryptography Engine</li>
573 The <b>source</b> flag installs a zip of the source code of a package.
574 This is traditionally used for for IDEs to 'attach' source to the libraries
575 you are using.
576 </li>
577 <li> 644 <li>
578 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
579 javadoc. 646 javadoc.
580 </li> 647 </li>
581</ul> 648</ul>
613 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
614 <uri 681 <uri
615 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>
616 mailing list archives 683 mailing list archives
617 </li> 684 </li>
618 <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>
619 <li> 689 <li>
620 <uri 690 <uri
621 link="http://en.wikipedia.org/wiki/Java_programming_language">Wikipedia's 691 link="http://en.wikipedia.org/wiki/Java_programming_language">Wikipedia's
622 entry for Java</uri> 692 entry for Java</uri>
623 </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>
624</ul> 698</ul>
625 699
626</body> 700</body>
627</section> 701</section>
628</chapter> 702</chapter>

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

  ViewVC Help
Powered by ViewVC 1.1.20