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.
then run
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/
Comments
sudo aptitude install sun-java6-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
No candidate version found for sun-java6-jdk
No candidate version found for sun-java6-jdk
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
Need to get 0B of archives. After unpacking 0B will be used.
Writing extended state information... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
I'm running UBuntu 10.04 LTS Lucid Lynx
Is there anything wrong?
edit your /etc/apt/souce.list and add at the bottom of the file the line :
deb http://archive.canonical.com/ lucid partner
(if it's not already there)
then,
sudo aptitude update
sudo aptitude upgrade (you've got 5 un-upgraded package)
sudo aptitue install sun-java-jdk
I've check and this repo contains the sun jdk.
Thomas.
I guess I had the partner repo before this upgrade or I just forgot to mention the fact that I added it.
Just checked /etc/apt/sources.list, it has the following lines:
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu lucid partner
# deb-src http://archive.canonical.com/ubuntu lucid partner
I'll uncomment the line "deb http://archive.canonical.com/ubuntu lucid partner"
I installed android adt plug in for eclipse and was getting error:
parseSdkContent failed
when setting the source folder for the android sdk.
Figured it was open java.
I made sun java jdk default and everything works now.
My init script
(
/etc/init.d/tomcat
for :
service tomcat stop; service tomcat start)
# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid
JAVA_HOME=/usr/lib/jvm/java-6-sun; export JAVA_HOME
JAVA_OPTS="-server -Xms512m -Xmx1024m -XX:MaxPermSize=512m -Dmail.mime.decodeparameters=true -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dmail.mime.decodeparameters=true"; export JAVA_OPTS
CATALINA_HOME=/usr/local/tomcat; export CATALINA_HOME
CATALINA_BASE=/home/special/tomcat; export CATALINA_BASE
case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
sudo update-java-alternatives -s java-6-sun
I am using 11.04 and I have a problem running the command "sudo aptitude update". It says command not found. Did the command change in 11.04?
If you get prompt a password while running "sudo aptitute update", that means that it's aptitude that is missing, you may need to install it (apt-get install aptitude)
if not, you may not be in the sudoers group...
I'll bet on the first option as sudo is a basic security feature of Ubuntu.
Package: aptitude
State: installed
Automatically installed: no
Version: 0.6.3-3.2ubuntu1
Priority: optional
Section: admin
>>>>Automatically installed: no
So I think it's the first option...
You can safely use "apt-get", aptitude is a frontend to apt-get.