Friday, September 26, 2008

Java 6 update 10 on Ubuntu 8.04

The official Ubuntu 8.04 repositories comes with a slightly outdated version of Java, namely 1.6.0 update 6. If you issue a java -version you can assert this is the case:

Unfortunately, if you are running Compiz, you are likely to then suffer the notorious gray rectangle syndrome as described in 6429775, 6434227 and 6632124 among others. The good news, the problem appears to be fixed in update 10.

Installing the latest JDK
Start by downloading the JDK for your architecture from SUN. Take the .bin file, extract it by running it as a shell script:

sh jdk-6u10-rc2-bin-b32-linux-amd64-12_sep_2008.bin

This will create a new folder called /jdk1.6.0_10. Rename this to java-6-sun- (just to remain consistent with how Debian/Ubuntu refers to JDK's) and move this folder to /usr/lib/jvm:

sudo mv jdk1.6.0_10 java-6-sun-
sudo mv jdk1.6.0_10/ /usr/lib/jvm

Officially you are suppose to use the update-java-alternatives command when using a Debian distro, but frankly I find it easier to do this manually. We need to update the /usr/lib/jvm/.java-6-sun.jinfo, so type:

gksu gedit .java-6-sun.jinfo

This will open up a hidden configuration file. The first line likely shows:


Simply change this to point to the new version:


Also, update the java 6 symlink to point to the one we just installed:

sudo rm /usr/lib/jvm/java-6-sun
sudo ln -s /usr/lib/jvm/java-6-sun- /usr/lib/jvm/java-6-sun

This should actually work for most applications, but to be sure I always like to add a few common environment variables. Do this by typing:

gksu gedit $HOME/.bashrc

Scroll down to the end of the file and add two new lines:

export JDK_HOME=/usr/lib/jvm/java-6-sun

That should do it. Issuing a java -version command now yields the latest version:

Remember the above isn't necessarily the official sanctioned way to do it, but it worked for me. Good luck to you!

It has come to my attention that Ubuntu 8.04 updates to the JVM overrides/reverts the modifications above. Keep an eye on this, I noticed it when starting seeing Compiz grey-box frames again in NetBeans.

Post a Comment