Pages

Monday, July 5, 2010

Ubuntu 10.04 : Install and set Sun JDK as default

For Ubuntu 10.04 LTS, the sun-java6  packages have been dropped from the Multiverse section of the Ubuntu archive. It is recommended that you use openjdk-6 instead.

If you can not switch from the proprietary Sun JDK/JRE to OpenJDK, you can install sun-java6 packages from the Canonical Partner Repository. You can configure your system to use this repository via command-line:
add-apt-repository “deb http://archive.canonical.com/ lucid partner”
You can also enable it from system->Administration->Software Sources, second tab “other sources” and check the “http://archive.canonical.com/ lucid partner”

to install Sun JDK back you just have to run :
sudo aptitude install sun-java6-jre sun-java6-plugin sun-java6-fonts sun-java6-jdk
 but after that, if you run java -version, it's still the openjdk version.
odus@xodus:~$ java -version
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
OpenJDK Server VM (build 14.0-b16, mixed mode)
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
odus@xodus:~$ sudo update-alternatives --config java
[sudo] password for odus:
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.

odus@xodus:~$ java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Server VM (build 16.3-b01, mixed mode)
odus@xodus:~$
Source:
http://www.ubuntugeek.com/sun-java-moved-to-the-partner-repository-in-ubuntu-10-04-lucid.html
http://blog.mansonthomas.com/2010/05/ubuntu-1004-install-and-set-sun-jdk-as.html

1 comment:

Simo said...

Thank you. It helps me to install Processing IDE. I only had to give the script permissions and now it works perfectly with Sun JDK.