| 1 |
neysx |
1.11 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
|
|
<!-- $Header: /home/cvsroot/gentoo/xml/htdocs/doc/en/java.xml,v 1.10 2003/11/16 15:35:59 swift Exp $ -->
|
| 3 |
swift |
1.8 |
<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
|
| 4 |
zhen |
1.4 |
|
| 5 |
neysx |
1.11 |
<guide link="/doc/en/java.xml">
|
| 6 |
|
|
<title>Gentoo Java Guide</title>
|
| 7 |
|
|
|
| 8 |
|
|
<author title="Author and Editor">
|
| 9 |
|
|
<mail link="karltk@gentoo.org">Karl Trygve Kalleberg</mail>
|
| 10 |
|
|
</author>
|
| 11 |
|
|
<author title="Editor">
|
| 12 |
|
|
<mail link="swift@gentoo.org">Sven Vermeulen</mail>
|
| 13 |
|
|
</author>
|
| 14 |
|
|
|
| 15 |
|
|
<abstract>
|
| 16 |
|
|
Users' and Developers' Guide to Java in Gentoo
|
| 17 |
|
|
</abstract>
|
| 18 |
|
|
|
| 19 |
|
|
<license/>
|
| 20 |
|
|
|
| 21 |
|
|
<version>0.1.3</version>
|
| 22 |
|
|
<date>November 16, 2003</date>
|
| 23 |
|
|
|
| 24 |
|
|
<chapter>
|
| 25 |
|
|
<title>Installing a JDK/JRE</title>
|
| 26 |
|
|
<section>
|
| 27 |
|
|
<title>Overview</title>
|
| 28 |
|
|
<body>
|
| 29 |
|
|
|
| 30 |
|
|
<p>
|
| 31 |
|
|
Gentoo provides numerous JDKs and JREs. The default is the Blackdown JDK/JRE
|
| 32 |
|
|
pair, as it is freely (beer) available without any registration fuss.
|
| 33 |
|
|
</p>
|
| 34 |
|
|
|
| 35 |
|
|
<note>
|
| 36 |
|
|
As kaffe becomes a JRE/JDK drop-in replacement, that will most likely become our
|
| 37 |
|
|
default.
|
| 38 |
|
|
</note>
|
| 39 |
|
|
|
| 40 |
|
|
<p>
|
| 41 |
|
|
Both the Sun JDK/JRE and the IBM JDK/JRE are generally faster, but getting them
|
| 42 |
|
|
is a bit more work, as you are required to read and accept their license before
|
| 43 |
|
|
downloading (IBM additionally requires you to register).
|
| 44 |
|
|
</p>
|
| 45 |
|
|
|
| 46 |
|
|
<p>
|
| 47 |
|
|
Our ebuilds for the Sun and IBM JDK/JREs will notify you of where to go to
|
| 48 |
|
|
download them.
|
| 49 |
|
|
</p>
|
| 50 |
|
|
|
| 51 |
|
|
</body>
|
| 52 |
|
|
</section>
|
| 53 |
|
|
|
| 54 |
|
|
<section>
|
| 55 |
|
|
<title>Installing the Sun/IBM JDK/JREs</title>
|
| 56 |
|
|
<body>
|
| 57 |
|
|
|
| 58 |
|
|
<p>
|
| 59 |
|
|
If you run <c>emerge sun-jdk-1.3.1</c> or <c>emerge ibm-jdk-1.3.1</c>, you will
|
| 60 |
|
|
be notified that you are required to download the actual tarballs yourself. This
|
| 61 |
|
|
has to do with license restrictions for the Sun JDK/JRE (online click-wrap
|
| 62 |
|
|
license) and registration issues with the IBM JDK/JRE.
|
| 63 |
|
|
</p>
|
| 64 |
|
|
|
| 65 |
|
|
<note>
|
| 66 |
|
|
There is also a sun-jdk-1.4.0, but not all packages work nicely with Java 1.4,
|
| 67 |
|
|
so you're on your own if you use the 1.4.0 JDK.
|
| 68 |
|
|
</note>
|
| 69 |
|
|
|
| 70 |
|
|
<p>
|
| 71 |
|
|
You should download the indicated file(s) into
|
| 72 |
|
|
<path>/usr/portage/distfiles</path>. Once that is done, you can rerun the emerge
|
| 73 |
|
|
command, then the JDK/JRE will be installed properly into <path>/opt</path>.
|
| 74 |
|
|
</p>
|
| 75 |
|
|
|
| 76 |
|
|
</body>
|
| 77 |
|
|
</section>
|
| 78 |
|
|
</chapter>
|
| 79 |
|
|
|
| 80 |
|
|
<chapter>
|
| 81 |
|
|
<title>Configuring your JDK/JRE</title>
|
| 82 |
|
|
<section>
|
| 83 |
|
|
<title>Overview</title>
|
| 84 |
|
|
<body>
|
| 85 |
|
|
|
| 86 |
|
|
<p>
|
| 87 |
|
|
Gentoo has the ability to have multiple JDKs and JREs installed without them
|
| 88 |
|
|
conflicting.
|
| 89 |
|
|
</p>
|
| 90 |
|
|
|
| 91 |
|
|
<p>
|
| 92 |
|
|
Using the <c>java-config</c> tool, you can set the system-wide default if you
|
| 93 |
|
|
have root access. Users can also use <c>java-config</c> to set up their own
|
| 94 |
|
|
personal default, that is different from the system-wide default.
|
| 95 |
|
|
</p>
|
| 96 |
|
|
|
| 97 |
|
|
</body>
|
| 98 |
|
|
</section>
|
| 99 |
|
|
|
| 100 |
|
|
<section>
|
| 101 |
|
|
<title>Setting a default JDK/JRE</title>
|
| 102 |
|
|
<body>
|
| 103 |
|
|
|
| 104 |
|
|
<p>
|
| 105 |
|
|
Running the command <c>java-config --list-available-vms</c> will give you a list
|
| 106 |
|
|
of all availble JREs and JDKs on your system, thus:
|
| 107 |
|
|
</p>
|
| 108 |
|
|
|
| 109 |
|
|
<pre caption="Listing available VMs">
|
| 110 |
drobbins |
1.1 |
[%1 ~] java-config --list-available-vms
|
| 111 |
|
|
[blackdown-jdk-1.3.1] Blackdown JDK 1.3.1 (/etc/env.d/java/20blackdown-jdk-1.3.1)
|
| 112 |
|
|
[blackdown-jre-1.3.1] Blackdown JRE 1.3.1 (/etc/env.d/java/20blackdown-jre-1.3.1)
|
| 113 |
|
|
[ibm-jdk-1.3.0] IBM JDK 1.3.0 (/etc/env.d/java/20ibm-jdk-1.3.0)
|
| 114 |
|
|
[ibm-jdk-1.3.1] IBM JDK 1.3.1 (/etc/env.d/java/20ibm-jdk-1.3.1)
|
| 115 |
|
|
[ibm-jre-1.3.1] IBM JRE 1.3.1 (/etc/env.d/java/20ibm-jre-1.3.1)
|
| 116 |
|
|
[sun-jdk-1.4.0] Sun JDK 1.4.0 (/etc/env.d/java/20sun-jdk-1.4.0)
|
| 117 |
neysx |
1.11 |
</pre>
|
| 118 |
|
|
|
| 119 |
|
|
<p>
|
| 120 |
|
|
The name in the brackets <path>"[]"</path> is the handle or ID for that
|
| 121 |
|
|
particular VM. You use pass that ID to <c>java-config --set-system-vm</c>, thus:
|
| 122 |
|
|
</p>
|
| 123 |
zhen |
1.4 |
|
| 124 |
neysx |
1.11 |
<pre caption="Setting the System VM">
|
| 125 |
drobbins |
1.1 |
[#1 ~] java-config --set-system-vm=ibm-jdk-1.3.1
|
| 126 |
|
|
Now using IBM JDK 1.3.1 (/etc/env.d/java/20ibm-jdk-1.3.1)
|
| 127 |
neysx |
1.11 |
</pre>
|
| 128 |
drobbins |
1.1 |
|
| 129 |
neysx |
1.11 |
<note>
|
| 130 |
|
|
You will have to be root to run --set-system-vm.
|
| 131 |
|
|
</note>
|
| 132 |
|
|
|
| 133 |
|
|
<p>
|
| 134 |
|
|
Once you have issued <c>java-config --set-system-vm</c> with a particular VM ID,
|
| 135 |
|
|
you will need to regenerate your /etc/profile.env, thus:
|
| 136 |
|
|
</p>
|
| 137 |
drobbins |
1.1 |
|
| 138 |
neysx |
1.11 |
<pre caption="Regenerating /etc/profile.env" >
|
| 139 |
drobbins |
1.1 |
[#1 ~] env-update
|
| 140 |
neysx |
1.11 |
</pre>
|
| 141 |
drobbins |
1.1 |
|
| 142 |
neysx |
1.11 |
<p>
|
| 143 |
|
|
After this, you will either want to relogin, or resource
|
| 144 |
|
|
<path>/etc/profile</path> into your environment.
|
| 145 |
|
|
</p>
|
| 146 |
|
|
|
| 147 |
|
|
<p>
|
| 148 |
|
|
As a regular user, you can use <c>java-config --set-user-vm</c>, which will
|
| 149 |
|
|
create <path>$HOME/.gentoo/java-env</path> with all required env vars. You would
|
| 150 |
|
|
normally source this from your shell's startup script
|
| 151 |
|
|
(<path>$HOME/.zshenv</path> in my case).
|
| 152 |
|
|
</p>
|
| 153 |
|
|
|
| 154 |
|
|
</body>
|
| 155 |
|
|
</section>
|
| 156 |
|
|
|
| 157 |
|
|
<section>
|
| 158 |
|
|
<title>Setting a default CLASSPATH</title>
|
| 159 |
|
|
<body>
|
| 160 |
|
|
|
| 161 |
|
|
<p>
|
| 162 |
|
|
<c>java-config</c> can also be used to set a system-wide default CLASSPATH, and
|
| 163 |
|
|
of course a user-specific default CLASSPATH.
|
| 164 |
|
|
</p>
|
| 165 |
|
|
|
| 166 |
|
|
<p>
|
| 167 |
|
|
First you want to list available java libraries that might be interesting to put
|
| 168 |
|
|
in your CLASSPATH, thus:
|
| 169 |
|
|
</p>
|
| 170 |
|
|
|
| 171 |
|
|
<pre caption="Listing classes">
|
| 172 |
drobbins |
1.1 |
[%1 ~] java-config --list-available-packages
|
| 173 |
|
|
[ant] No description (/usr/share/ant/classpath.env)
|
| 174 |
|
|
[java-gnome] No description (/usr/share/java-gnome/classpath.env)
|
| 175 |
|
|
[java-gtk] No description (/usr/share/java-gtk/classpath.env)
|
| 176 |
|
|
[log4j] "" (/usr/share/log4j/package.env)
|
| 177 |
neysx |
1.11 |
</pre>
|
| 178 |
zhen |
1.4 |
|
| 179 |
neysx |
1.11 |
<note>
|
| 180 |
|
|
None of these packages have a proper description. That is something that will be
|
| 181 |
|
|
implemented in the not-so-distant future.
|
| 182 |
|
|
</note>
|
| 183 |
|
|
|
| 184 |
|
|
<p>
|
| 185 |
|
|
Again, the name in brackets <path>"[]"</path> are the IDs that you have to pass
|
| 186 |
|
|
to <c>java-config --set-system-classpath</c>, thus:
|
| 187 |
|
|
</p>
|
| 188 |
drobbins |
1.1 |
|
| 189 |
neysx |
1.11 |
<pre caption="Setting classpaths">
|
| 190 |
drobbins |
1.1 |
java-config --set-system-classpath=log4j,java-gtk,java-gnome
|
| 191 |
neysx |
1.11 |
</pre>
|
| 192 |
|
|
|
| 193 |
|
|
<note>
|
| 194 |
|
|
The current directory (.) will not be part of the system classpath, as that
|
| 195 |
|
|
should be added in root's login profile.
|
| 196 |
|
|
</note>
|
| 197 |
|
|
|
| 198 |
|
|
<p>
|
| 199 |
|
|
Again, you will want to run <c>env-update</c> to update your system's
|
| 200 |
|
|
environment, and you might also want to relogin or resource the
|
| 201 |
|
|
<path>/etc/profile</path>.
|
| 202 |
|
|
</p>
|
| 203 |
|
|
|
| 204 |
|
|
<p>
|
| 205 |
|
|
For users, <c>java-config --set-user-classpath</c> will create
|
| 206 |
|
|
<path>$HOME/.gentoo/java-env-classpath</path>, which is automatically included
|
| 207 |
|
|
by <path>$HOME/.gentoo/java-env</path>.
|
| 208 |
|
|
</p>
|
| 209 |
|
|
|
| 210 |
|
|
</body>
|
| 211 |
|
|
</section>
|
| 212 |
|
|
</chapter>
|
| 213 |
|
|
|
| 214 |
|
|
<chapter>
|
| 215 |
|
|
<title>Additional resources</title>
|
| 216 |
|
|
<section>
|
| 217 |
|
|
<title>Off-line resources</title>
|
| 218 |
|
|
<body>
|
| 219 |
|
|
|
| 220 |
|
|
<ul>
|
| 221 |
|
|
<li>java-config man page</li>
|
| 222 |
|
|
<li><c>java-config --help</c></li>
|
| 223 |
|
|
<li>The <path>/usr/bin/java-config</path> script itself</li>
|
| 224 |
|
|
</ul>
|
| 225 |
|
|
|
| 226 |
|
|
</body>
|
| 227 |
|
|
</section>
|
| 228 |
|
|
|
| 229 |
|
|
<section>
|
| 230 |
|
|
<title>Online resources</title>
|
| 231 |
|
|
<body>
|
| 232 |
|
|
|
| 233 |
|
|
<ul>
|
| 234 |
|
|
<li>The <uri link="http://news.gmane.org/gmane.linux.gentoo.devel"
|
| 235 |
|
|
>gentoo-dev</uri>, <uri link="http://news.gmane.org/gmane.linux.gentoo.user"
|
| 236 |
|
|
>gentoo-user </uri> mailing list archives</li>
|
| 237 |
|
|
<li>#gentoo on irc.openprojects.net</li>
|
| 238 |
|
|
</ul>
|
| 239 |
|
|
|
| 240 |
|
|
</body>
|
| 241 |
|
|
</section>
|
| 242 |
|
|
</chapter>
|
| 243 |
|
|
</guide> |