Ubuntu 10.04 : Install and set Sun JDK as default
Since ubuntu 10.04, Sun JDK has been dropped and replaced by openjdk.
Literally replaced, ie : Sun JDK remove, openjdk installed.
This is performed during the upgrade without explicitly asking you for your consent...
which is quite ugly... After the upgrade, my tomcat was not working anymore...
Anyway, in order to install Sun JDK back you just have to :
vi /etc/apt/sources.listand check if the following line is present :
deb http://archive.canonical.com/ lucid partnerif not, add it at the end of the file.
sudo aptitude update
to get the package list from the new repo.
and then run :
sudo aptitude install sun-java6-jdkbut after that, if you run java -version, it's still the openjdk version.
thomas@daisybox:/usr/lib/jvm/java-6-sun$ java -version java version "1.6.0_18" OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1) OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode) thomas@daisybox:/usr/lib/jvm/java-6-sun$ which java /usr/bin/java thomas@daisybox:/usr/lib/jvm/java-6-sun$ ll /usr/bin/java lrwxrwxrwx 1 root root 22 2010-05-11 23:44 /usr/bin/java -> /etc/alternatives/java thomas@daisybox:/usr/lib/jvm/java-6-sun$ ll /etc/alternatives/java lrwxrwxrwx 1 root root 40 2010-05-11 23:44 /etc/alternatives/java -> /usr/lib/jvm/java-6-openjdk/jre/bin/java
You could try to remove openjdk, but you'll hit some annoying dependency issue.
Instead of removing you can configure the system to default to Sun JDK
thomas@daisybox:~$ sudo update-alternatives --config java There are 2 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode 1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode 2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode Press enter to keep the current choice[*], or type selection number: 2 update-alternatives: using /usr/lib/jvm/java-6-sun/jre/bin/java to provide /usr/bin/java (java) in manual mode. thomas@daisybox:/usr/lib/jvm/java-6-sun$ ll /etc/alternatives/java lrwxrwxrwx 1 root root 36 2010-05-11 23:48 /etc/alternatives/java -> /usr/lib/jvm/java-6-sun/jre/bin/java thomas@daisybox:~$ java -version java version "1.6.0_20" Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)
Or more directly like "Daniel Bos" suggest in the comments :
sudo update-java-alternatives -s java-6-sun
image taken from : http://www.sucka.net/2010/04/jdk-linux-update-script/