Thursday, November 30, 2006

Ubuntu java, moving from 1.4 to 1.5 using java alternatives

Today I migrated my box at home to Ubuntu Edgy (6.10), went pretty smooth but borked out my locales (I can deal with that) and removed Perl for some reason. After straightening that out I wanted to move on to java 1.5 for my Java projects. This is when I hit the 'java alternatives' setup in Ubuntu for the first time.

The problem is I don't want to remove java 1.4 so I had to figure out how to reset the links in the alternatives system to point to java 1.5 and not java 1.4 anymore. Here is what I did:

# first install java 1.5. 
$ sudo aptitude install sun-java5-jre

# After the install finished I still had java 1.4 linked via the alternative system.
$ java -version

java version "1.4.2-02" 
Java(TM) 2 Runtime Environment, Standard Edition (build Blackdown-1.4.2-02) 
Java HotSpot(TM) 64-Bit Server VM (build Blackdown-1.4.2-02, mixed mode)

# here we can look at the current settings in the alternatives system. 
$ sudo update-java-alternatives --list

java-1.5.0-sun 53 /usr/lib/jvm/java-1.5.0-sun

# we want the 1.5 version so need to set that. 
$ sudo update-java-alternatives --set java-1.5.0-sun

# results are clearly that we are on java 1.5 now! 
$ java -version

java version "1.5.0_06" 
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) 
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_06-b05, mixed mode)