Jumat, 25 April 2014

Uninstall Java from Ubuntu Linux

Introduction

Hopefully you won’t need these instructions due to a botched install, but there may come a time where you need to uninstall a version of the JDK/JVM.
These instructions are for the Oracle JDK 1.7.0 Update 4 on Ubuntu 12.04 LTS. If you are using a different version of the JDK, then change the version numbers listed below.
I have also included instructions for removing the OpenJDK at the bottom of this post.

Uninstall Java

Let’s check the current setup before we uninstall Java.
sudo update-alternatives --display java
The output from the command will be something like:

java - manual mode
link currently points to /usr/lib/jdk1.7.0_04/bin/java
/usr/lib/jdk1.7.0_04/bin/java - priority 1
/usr/lib/jvm/j2sdk1.6-oracle/jre/bin/java - priority 315
slave java.1.gz: /usr/lib/jvm/j2sdk1.6-oracle/man/man1/java.1.gz
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java - priority 1051
slave java.1.gz: /usr/lib/jvm/java-7-openjdk-amd64/jre/man/man1/java.1.gz
Current 'best' version is '/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java'.

Next, we’ll remove each symlink to a Java binary from the Debian alternatives system. I have split the following commands onto multiple lines to ensure that they display correctly on this page. However, you can remove the \ and then type each command on one line in the terminal.
sudo update-alternatives --remove "java" \
"/usr/lib/jvm/jdk1.7.0_04/bin/java"
sudo update-alternatives --remove "javac" \
"/usr/lib/jvm/jdk1.7.0_04/bin/javac"
sudo update-alternatives --remove "javaws" \
"/usr/lib/jvm/jdk1.7.0_04/bin/javaws"
Let’s quickly verify that the commands above remove the symlinks.
java -version
javac -version
which javaws
You should no longer see 1.7.0 u04 for the version of any of the above commands.
IMPORTANT WARNING
You must type the next 2 commands perfectly to avoid permanently destroying your system. If you do this wrong, you could delete important system files, including those that are required by Ubuntu.
cd /usr/lib/jvm
sudo rm -rf jdk1.7.0_04
sudo update-alternatives --config java
Output:
update-alternatives: error: no alternatives for java.
sudo update-alternatives --config javac
Output:
update-alternatives: error: no alternatives for javac.
sudo update-alternatives --config javaws
Output:
update-alternatives: error: no alternatives for javaws.
sudo vi  /etc/environment
Delete the line with JAVA_HOME

Uninstall OpenJDK (if installed)

First we’ll check which OpenJDK packages are installed.
sudo dpkg --list | grep -i jdk
Next, let’s uninstall OpenJDK related packages. Edit the list of packages below if you have additional or different OpenJDK packages installed.
sudo apt-get purge icedtea-* openjdk-*
Let’s check that all OpenJDK packages have been removed.
sudo dpkg --list | grep -i jdk
 
 
 
sumber =  http://akbarahmed.com/2012/06/24/uninstall-java-from-ubuntu-linux/

Tidak ada komentar:

Posting Komentar