i searched and not found how to upgrade oracle jdk in here. I'm not satisfied with OpenJDK7 because it doesn't come with Java Compiler.

I have installed and configured Sun Java SDK 6 and I want to upgrade to Oracle JDK 7. I searched ppa's from launchpad an wubp8 but it didn't worked . How can I upgrade Sun JDK 6 to Oracle JDK 7 and also completely remove all Sun JDK 6 settings?

I'm very grateful for your answers.

  • Go here to the following link: askubuntu.com/questions/55848/… – Petronilla Escarabajo Mar 30 '12 at 0:45
  • thank you, i'm very pleased with you. i want to remove all setting and configure Sun JDK 6 and start clearly Oracle JDK. – obysr Mar 30 '12 at 0:51
  • can everyone help me?? – obysr Mar 30 '12 at 8:37
  • To upgrade from Sun JDK 6 to Oracle JDK 7, you will first need to install Oracle JDK 7. Then remove all other versions of JDK on your system. What version of Ubuntu are you running? – Petronilla Escarabajo Mar 30 '12 at 15:22
  • I'm running 11.10 Oneiric Ocelot. What should i do? – obysr Mar 30 '12 at 22:26

Upgrade may cause problems , so its better to do a fresh install.

Completely remove Open-jdk

just use this simple commands in terminal to remove open jdk completely

sudo apt-get purge openjdk-\*

How to install Oracle-Java

To get an automatically update-able Java from Oracle, you can you use the PPA provided from webup8.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

Installing Oracle Java manually

For installing Latest Oracle Java:

To check ubuntu system architecture installed

$ uname -m


$ arch

Download the Oracle Java JDK for Linux. Make sure you select the correct compressed binaries for your system architecture 32-bit or 64-bit (which end in tar.gz).It will be downloaded in Downloads folder in home.So first open nautilus with sudo as

sudo nautilus 

and make a folder java under


and then folow the following commands:

cd /home/"your_user_name"/Downloads
sudo cp -r jdk-7u40-linux-x64.tar.gz /usr/local/java
cd /usr/local/java
sudo chmod a+x jdk-7u40-linux-x64.tar.gz
sudo tar xvzf jdk-7u40-linux-x64.tar.gz

At this point you should have two uncompressed binary directories in /usr/local/java check it by

ls -a

Now edit the system path file by

sudo gedit /etc/profile

scroll down to the last and add following lines

export JAVA_HOME
export PATH

Save and exit and write these commands in terminal to Inform your Ubuntu Linux system where your Oracle Java JDK/JRE is located.

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.7.0_40/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0_40/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.7.0_40/bin/javaws" 1
sudo update-alternatives --set java /usr/local/java/jdk1.7.0_40/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.7.0_40/bin/javac
sudo update-alternatives --set javaws /usr/local/java/jdk1.7.0_40/bin/javaws
. /etc/profile

Now everything is installed just check it by

java -version

the output must be like

java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b40)
Java HotSpot(TM) Server VM (build 23.1-b03, mixed mode)

Congratulation now its installed.


Please follow one of the suggested answers in the following Ask Ubuntu question:

How do I install Oracle Java JDK 7?

this should be able to update your jdk6 to jdk7.

My version is: 1.7.0_03

  • rather than repeating information that can quickly get out outdate - please link to an AskUbuntu Q&A (there are several) and just add the extra information the OP is seeking about "removing" his java version. Thanks. – fossfreedom Apr 1 '12 at 22:00
  • Outdated? I just used this same process less than an hour ago to update one of my machines. I thought his question was asking how to upgrade. However your more than welcome to add the extra info. – st2011 Apr 1 '12 at 22:10
  • updated your answer - however it still doesnt cover "removing JDK settings" – fossfreedom Apr 1 '12 at 22:13
  • Just to be clear he did state, "i searched and not found how to upgrade oracle jdk in here." So thats why I was sharing "customize" steps. But your "update" I guess is better and you can also provide in your update what wasn't cover as well. -Thanks. – st2011 Apr 1 '12 at 22:24
  • thank you sir.. but it doens't help anything T_T everybody help me please – obysr Apr 3 '12 at 0:46

First uninstall:

sudo apt-get purge openjdk-7-jre

Here you go to install the latest Java version 8 on Ubuntu, both JRE and JDK:

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

sudo apt-get -f upgrade

sudo apt-get autoremove

sudo apt-get install oracle-java8-installer

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.