Tuesday, October 17, 2017

Install / Uninstall JAVA In Linux/Unix

JAVA installation

# mkdir -p /usr/local/java

# tar xvzf /opt/jdk-8u131-linux-x64.tar.gz -C /usr/local/java

# echo "JAVA_HOME=/usr/local/java/jdk1.8.0_131" >> /etc/profile

# echo "PATH=$PATH:$HOME/bin:$JAVA_HOME/bin" >> /etc/profile

# echo "export JAVA_HOME" >> /etc/profile

# echo "export PATH" >> /etc/profile

# update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_131/bin/java" 1

# update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_131/bin/javac" 1

# update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_131/bin/javaws" 1

# update-alternatives --set java /usr/local/java/jdk1.8.0_131/bin/java

# update-alternatives --set javac /usr/local/java/jdk1.8.0_131/bin/javac

# update-alternatives --set javaws /usr/local/java/jdk1.8.0_131/bin/javaws

# source /etc/profile

--------------------

Delete/Remove Java

# sudo update-alternatives --remove "java" "/usr/lib/jvm/jdk<version>/bin/java"

# sudo update-alternatives --remove "javac" "/usr/lib/jvm/jdk<version>/bin/javac"

# sudo update-alternatives --remove "javaws" "/usr/lib/jvm/jdk<version>/bin/javaws"

verify that the symlinks were removed

# java -version

# javac -version

# which javaws

# cd /usr/lib/jvm

# sudo rm -rf jdk<version>

# sudo update-alternatives --config java

# sudo update-alternatives --config javac

# sudo update-alternatives --config javaws

# sudo vi  /etc/environment

Delete the line with JAVA_HOME 1

Java for MOtadata----------------------

# JAVA_HOME="/motadata/motadata/jdk/"

# source /etc/environment

# echo $JAVA_HOME
/motadata/motadata/jdk/

# echo "JAVA_HOME=/motadata/motadata/jdk">> /etc/profile

# echo "PATH=$PATH:$HOME/bin:$JAVA_HOME/bin" >> /etc/profile

# echo "export JAVA_HOME" >> /etc/profile

# echo "export PATH" >> /etc/profile

# update-alternatives --install "/usr/bin/java" "java" "/motadata/motadata/jdk/bin/java" 1

# update-alternatives: using /motadata/motadata/jdk/bin/java to provide /usr/bin/java (java) in auto mode

# update-alternatives --install "/usr/bin/javac" "javac" "/motadata/motadata/jdk/bin/javac" 1

# update-alternatives: using /motadata/motadata/jdk/bin/javac to provide /usr/bin/javac (javac) in auto mode

# update-alternatives --install "/usr/bin/javaws" "javaws" "/motadata/motadata/jdk/bin/javaws" 1      

update-alternatives: using /motadata/motadata/jdk/bin/javaws to provide /usr/bin/javaws (javaws) in auto mode

# update-alternatives --set java /motadata/motadata/jdk/bin/java

# update-alternatives --set javac /motadata/motadata/jdk/bin/javac

# update-alternatives --set javaws /motadata/motadata/jdk/bin/javaws

# source /etc/profile

# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

No comments:

Post a Comment