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
or
$ 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
/usr/local/
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
JAVA_HOME=/usr/local/java/jdk1.7.0_40
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
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.
That may be an OpenJDK issue. Sometimes the Oracle JDK is required in order to get something to work.
Generally the JDKs are downwards compatible, you could as well use version 8.
Here is a tutorial how to install it: http://docs.oracle.com/javase/8/docs/technotes/guides/install/linux_jdk.html
If you already installed (read: put it somewhere on your drive) the Oracle JDK, you can choose it with
update-alternatives --config java
I had problems with that before, if the JDK you want isn't listed, you have to add it to update-alternatives first:
sudo update-alternatives --install /usr/bin/java java /path/to/your/jdk/bin 1
Replace /path/to/your with your path.
Best Answer
It could be done like this:
Remove the link:
Then, remove the package in the
/usr/lib/jvm
:Note :
Change [version] with any version number that's contained in jdk folder's name, example:
jdk[version] = jdk1.7.0_13
.If you are new to Linux, you should probably get familiar with the manual page. Lot of good stuff from there. Just go to the terminal and type
man update-alternatives
.