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-1.6.0.10 (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-1.6.0.10
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:


name=java-6-sun-1.6.0.06
...

Simply change this to point to the new version:


name=java-6-sun-1.6.0.10
...


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-1.6.0.10/ /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
export JAVA_HOME=$JDK_HOME


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!

Update:
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.


Comments

Anonymous said…
Thanks man, that helped. But I did't get why you copy the .jinfo file but only change the name to name=java-6-sun-1.6.0.10. All the links still point to the 1.6.0.06 installation ?!?!

To integrate update 10 into Ubuntus alternatives system(and also use the new browser plugin), I extended your description

http://java.randgestalten.de/?p=31

cheers
Casper Bang said…
Right, I have updated the blog entry. I forgot to mention you have to update the sym link:

sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.10/ java-6-sun
Honza said…
Hi,

thanks for a nice quick howto.

To make "cut-and-paste" suitable, change the command
sudo mv jdk1.6.0_10/ /usr/lib/jvm
to
sudo mv java-6-sun-1.6.0.10/ /usr/lib/jvm
Casper Bang said…
Thanks for the tip honza, I am still learning obviously ;)
Wim Deblauwe said…
What will happen if ubuntu itself updates? Will this update be overwritten or will it fail? Anybody has an idea?

Popular posts from this blog

Oracle SQLDeveloper 4 on Debian/Ubuntu/Mint

@SuppressWarnings values

Rejsekort Scanner