Did you know, that there is a really simple way to set your Java environment in Ubuntu, when you have multiple Java packages installed?
Everything you need is to run update-java-alternatives command with correct parameters.
Just look at your installed Java packages (use ls -l /usr/lib/jvm/ command):
petr@pchytil-ws:~/nbsrc_main/main/mercurial$ ls -a1 /usr/lib/jvm/ . .. java-1.5.0-gcj-4.2-1.5.0.0 java-1.5.0-sun java-1.5.0-sun-1.5.0.15 .java-1.5.0-sun.jinfo java-6-sun java-6-sun-1.6.0.06 .java-6-sun.jinfo java-gcj .java-gcj.jinfo
You can see three .jinfo files here. Just take name of this files without extension and you have right parameters for update-java-alternatives command.
On my machine, I have three Java packages installed:
java-1.5.0-sun java-6-sun java-gcj
So choose the package you want and run
sudo update-java-alternatives -s <java_name>
for example i want to use JDK 6.0:
sudo update-java-alternatives -s java-6-sun
This command creates links for all important Java binaries. java -version command should now give you the Java version, which you always dreamed of
.
petr@pchytil-ws:~$ java -version java version "1.6.0_06" Java(TM) SE Runtime Environment (build 1.6.0_06-b02) Java HotSpot(TM) Server VM (build 10.0-b22, mixed mode)

