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