Anyhow, I've never been too happy with the Java that comes in the repositories, even the ones from Sun: they're a few minor releases old, and I think my students should work with the latest releases. I know I would, too. That's why I get my JDK and other stuff from the Sun Java web site.
How to get the latest version of Java running on Ubuntu?
1. First comes the download, around 80MB for the JDK (as of now, I am using
jdk-6u16-linux-i586.bin
).2. Being a self-extracting binary file, all you need to do is run it
sh jdk-6u16-linux-i586.bin
This should create a Java directory, in this case
jdk1.6.0_16/
.3. You could work directly with this directory where it is, but I think its proper place is in globally-accessible location, so I would transfer this to the
/opt
directory.sudo mv -p jdk1.6.0_16/ /opt/java/
4. Next, we need to tell the rest of the operating system where the Java directory is. Create a file
java.sh
in /etc/profile.d
, which contains the custom startup scripts. My java.sh
:export PATH=$PATH:/opt/java/jdk1.6.0_16/bin/
export JAVA_HOME=/opt/java/jdk1.6.0_16/
5. Finally, log off (not shut down, just log off) and log in again.
To test if Java is working, in your home directory just type
java -version
. This will show what version of Java you're running. In my case:java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Server VM (build 14.2-b01, mixed mode)