/[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.34 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.34 2006/10/08 22:52:16 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.10</version> 27<version>0.19</version>
28<date>2006-10-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 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
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>
294The following VMs are available for generation-2: 212The following VMs are available for generation-2:
2951) Blackdown JDK 1.4.2.03 [blackdown-jdk-1.4.2] 2131) Blackdown JDK 1.4.2.03 [blackdown-jdk-1.4.2] <comment>(Build Only)</comment>
2962) Blackdown JRE 1.4.2.03 [blackdown-jre-1.4.2] 2142) Blackdown JRE 1.4.2.03 [blackdown-jre-1.4.2] <comment>(Build Only)</comment>
2973) Blackdown 32bit JRE 1.4.2.03 [emul-linux-x86-java-1.4.2] 2153) IcedTea6-bin 1.4.1 [icedtea6-bin]
2984) Sun 32bit JRE 1.5.0.08 [emul-linux-x86-java-1.5] 2164) Sun JDK 1.5.0.20 [sun-jdk-1.5] <comment>(Build Only)</comment>
2995) Kaffe 1.1.7 [kaffe]
300*) Sun JDK 1.5.0.08 [sun-jdk-1.5] 217*) Sun JDK 1.6.0.16 [sun-jdk-1.6]
301</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>
302 226
303<p> 227<p>
304The <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
305set). 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
306particular 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
309 233
310<pre caption="Setting the System VM"> 234<pre caption="Setting the System VM">
311<comment>(By handle (preferred))</comment> 235<comment>(By handle (preferred))</comment>
312# <i>java-config --set-system-vm blackdown-jdk-1.4</i> 236# <i>java-config --set-system-vm blackdown-jdk-1.4</i>
313Now using blackdown-jdk-1.4 as your generation-2 system JVM 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.
314<comment>(By number)</comment> 239<comment>(By number)</comment>
315# <i>java-config --set-system-vm 6</i> 240# <i>java-config --set-system-vm 5</i>
316Now using sun-jdk-1.5 as your generation-2 system JVM 241Now using sun-jdk-1.6 as your generation-2 system JVM
317</pre> 242</pre>
318 243
319<p> 244<p>
320As 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>.
321</p> 246</p>
325VM take place. 250VM take place.
326</note> 251</note>
327 252
328</body> 253</body>
329</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>
330<section id="preferred-vm"> 273<section id="preferred-vm">
331<title>Preferred VM</title> 274<title>Preferred VM</title>
332<body> 275<body>
333 276
334<p> 277<p>
338<p> 281<p>
339Because 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
340test 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
341packages merges smoothly, we have defined a list of <e>default/supported 284packages merges smoothly, we have defined a list of <e>default/supported
342VMs</e> per arch. You can find them in 285VMs</e> per arch. You can find them in
343<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
344merging 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,
345it will automatically use that VM, instead of the system-vm. 288it will automatically use that VM, instead of the system-vm.
346</p> 289</p>
347 290
348<p> 291<p>
512</p> 455</p>
513 456
514<p> 457<p>
515For users, <c>java-config --set-user-classpath</c> will create 458For users, <c>java-config --set-user-classpath</c> will create
516<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
517your shell's profile. 460your shell's profile.
518</p> 461</p>
519 462
520<pre caption="Sourcing user specific classpath"> 463<pre caption="Sourcing user specific classpath">
521<i>if [[ -f "${HOME}/.gentoo/java-env-classpath" ]]; then 464<i>if [[ -f "${HOME}/.gentoo/java-env-classpath" ]]; then
522 source ${HOME}/.gentoo/java-env-classpath 465 source ${HOME}/.gentoo/java-env-classpath
528something 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
529against it. 472against it.
530</p> 473</p>
531 474
532<pre caption="Setting classpath"> 475<pre caption="Setting classpath">
533# <i>export CLASSPATH="${CLASSPATH}:$(java-config --classpath log4j,xerces-2)"</i> 476# <i>export CLASSPATH="${CLASSPATH}:$(java-config --classpath log4j,xerces-2)"</i>
534</pre> 477</pre>
535 478
536</body> 479</body>
537</section> 480</section>
538</chapter>
539
540<chapter> 481</chapter>
482
483<chapter>
541<title>Java Browser Plug-ins</title> 484<title>Java Browser Plugins</title>
542<section> 485<section>
543<title>Installing a plug-in</title> 486<title>Installing a plugin</title>
544<body> 487<body>
545 488
546<p> 489<p>
547You can install a Java plug-in for your web browser by emerging a Java VM with 490You can install a Java plugin for your web browser by emerging a Java VM with
548the <c>nsplugin</c> USE flag set. 491the <c>nsplugin</c> USE flag set.
549</p> 492</p>
550 493
551<note> 494<note>
552<c>nsplugin</c> is not available for all architectures. Check for available 495<c>nsplugin</c> is not available for all architectures. Check for available
553plug-ins on your arch before trying to install a VM by running <c>emerge -pv 496plugins on your arch before trying to install a VM by running <c>emerge -pv
554&lt;java-vm&gt;</c>. 497&lt;java-vm&gt;</c>.
555</note> 498</note>
556 499
557<p> 500<p>
558Portage will allow you to install multiple versions of Java plug-ins, though 501Portage will allow you to install multiple versions of Java plugins, though
559only one will be used by your browser. You can check the list of available 502only one will be used by your browser. You can check the list of available
560plug-ins by running: 503plugins by running:
561</p> 504</p>
562 505
563<pre caption="Viewing available plug-ins"> 506<pre caption="Viewing available plugins">
564# <i>eselect java-nsplugin list</i> 507# <i>eselect java-nsplugin list</i>
565 [1] sun-jre-bin-1.5 508 [1] sun-jre-bin-1.6
566 [2] blackdown-jre-1.4.2 509 [2] icedtea6-bin
567</pre> 510</pre>
568 511
569<p> 512<p>
570In this example, <c>sun-jre-bin</c> is selected for the browser plug-in. 513In this example, <c>sun-jre-bin</c> is selected for the browser plugin.
571</p> 514</p>
572 515
573<pre caption="Selecting a plug-in"> 516<pre caption="Selecting a plugin">
574# <i>eselect java-nsplugin sun-jre-bin-1.5</i> 517# <i>eselect java-nsplugin set sun-jre-bin-1.6</i>
575</pre> 518</pre>
576 519
577<p> 520<p>
578Verify that the correct plug-in was selected: 521Verify that the correct plugin was selected:
579</p> 522</p>
580 523
581<pre caption="Verifying the correct plug-in"> 524<pre caption="Verifying the correct plugin">
582# <i>eselect java-nsplugin list</i> 525# <i>eselect java-nsplugin list</i>
583 [1] sun-jre-bin-1.5 current 526 [1] sun-jre-bin-1.6 current
584 [2] blackdown-jre-1.4.2 527 [2] icedtea6-bin
585</pre> 528</pre>
586 529
587<p> 530<p>
588Java.com also provides a link to <uri 531Java.com also provides a link to <uri
589link="http://java.com/en/download/installed.jsp">verify your installed 532link="http://java.com/en/download/installed.jsp">verify your installed
590plug-in</uri>. Additionally, if you are using a Mozilla-based browser, you can 533plugin</uri>. Additionally, if you are using a Mozilla-based browser, you can
591verify your Java plug-in by typing <c>about:plugins</c> into the address bar. 534verify your Java plugin by typing <c>about:plugins</c> into the address bar.
592</p> 535</p>
593 536
594</body> 537</body>
595</section>
596<section> 538</section>
539<section>
597<title>Plug-ins on multilib systems</title> 540<title>Plugins on multilib systems</title>
598<body> 541<body>
599 542
600<p> 543<p>
601If you are running a mixed 64-bit and 32-bit multilib system (for example, on AMD64), 544If you are running a mixed 64-bit and 32-bit multilib system (for example, on
602you can have both 64-bit and a 32-bit Java plug-ins installed. 545AMD64), you can use 64-bit and 32-bit Java plugins. Unless you have a pressing
603</p> 546need to run 32-bit Java applications, we recommend using native 64-bit plugins
604 547on 64-bit web browsers.
605<p> 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>
606First, check which plug-ins are available: 572Next, check which plugins are available:
607</p> 573</p>
608 574
609<pre caption="Viewing available plug-ins"> 575<pre caption="Viewing available plugins">
610# <i>eselect java-nsplugin list</i> 576# <i>eselect java-nsplugin list</i>
611Available 32-bit Java browser plugins 577Available 32-bit Java browser plugins
612 [1] emul-linux-x86-java-1.4.2
613 [2] emul-linux-x86-java-1.5 578 [1] emul-linux-x86-java-1.5
579 [2] emul-linux-x86-java-1.6
614Available 64-bit Java browser plugins 580Available 64-bit Java browser plugins
615 [1] blackdown-jdk-1.4.2 581 [1] icedtea6-bin
616 [2] blackdown-jre-1.4.2 582 [2] sun-jre-bin-1.6
617</pre> 583</pre>
618 584
619<p>
620You can select a 32-bit plug-in for a 32-bit browser (for example,
621<c>firefox-bin</c>), and you can select a 64-bit plug-in for your 64-bit
622browser (for example, <c>konqueror</c>).
623</p> 585<p>
586Now select the right plugin for your browsers:
587</p>
624 588
625<pre caption="Selecting plug-ins"> 589<pre caption="Selecting plugins">
590<comment>(Choose the plugins for 32-bit and 64-bit browsers)</comment>
626# <i>eselect java-nsplugin set 32bit emul-linux-x86-java-1.4.2</i> 591# <i>eselect java-nsplugin set 32bit emul-linux-x86-java-1.6</i>
627# <i>eselect java-nsplugin set 64bit blackdown-jdk-1.4.2</i> 592# <i>eselect java-nsplugin set 64bit sun-jre-bin-1.6</i>
628</pre> 593</pre>
629 594
630<p> 595<p>
631Verify the correct plug-ins were selected: 596Verify the correct plugin was selected:
632</p> 597</p>
633 598
634<pre caption="Verifying the correct plug-ins"> 599<pre caption="Verifying the correct plugin">
635# <i>eselect java-nsplugin list</i> 600# <i>eselect java-nsplugin list</i>
636Available 32-bit Java browser plugins 601Available 32-bit Java browser plugins
637 [1] emul-linux-x86-java-1.4.2 current
638 [2] emul-linux-x86-java-1.5 602 [1] emul-linux-x86-java-1.5
603 [2] emul-linux-x86-java-1.6 current
639Available 64-bit Java browser plugins 604Available 64-bit Java browser plugins
640 [1] blackdown-jdk-1.4.2 current 605 [1] icedtea6-bin
641 [2] blackdown-jre-1.4.2 606 [2] sun-jre-bin-1.6 current
642</pre> 607</pre>
643 608
644</body> 609</body>
645</section> 610</section>
646</chapter> 611</chapter>
673 <li> 638 <li>
674 The <b>source</b> flag installs a zip of the source code of a package. 639 The <b>source</b> flag installs a zip of the source code of a package.
675 This is traditionally used for IDEs to 'attach' source to the libraries you 640 This is traditionally used for IDEs to 'attach' source to the libraries you
676 are using. 641 are using.
677 </li> 642 </li>
643 <li>The <b>jce</b> flag adds support for the Java Cryptography Engine</li>
678 <li> 644 <li>
679 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
680 javadoc. 646 javadoc.
681 </li> 647 </li>
682</ul> 648</ul>
714 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
715 <uri 681 <uri
716 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>
717 mailing list archives 683 mailing list archives
718 </li> 684 </li>
719 <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>
720 <li> 689 <li>
721 <uri 690 <uri
722 link="http://en.wikipedia.org/wiki/Java_programming_language">Wikipedia's 691 link="http://en.wikipedia.org/wiki/Java_programming_language">Wikipedia's
723 entry for Java</uri> 692 entry for Java</uri>
724 </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>
725</ul> 698</ul>
726 699
727</body> 700</body>
728</section> 701</section>
729</chapter> 702</chapter>

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

  ViewVC Help
Powered by ViewVC 1.1.20