How To Install Java on Ubuntu with Apt-Get & OEL ,RHEL with yum or manually

Spread the love

sudo apt-get update

java -version

To install OpenJDK 7, execute the following command:

sudo apt-get install openjdk-7-jre

sudo yum install openjdk-7-jdk

sudo apt-get install oracle-java6-installer

sudo apt-get install oracle-java7-installer

sudo apt-get install oracle-java8-installer

sudo update-alternatives –config java

It will usually return something like this if you have 2 installations
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
————————————————————
* 0 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 manual mode

Or download setup from oracle site and install java & configure manually

To set the JAVA_HOME environment variable

Set the path of the Java

Run in terminal

# alternatives –install /usr/bin/java java /jdk1.6/bin/java 120

Note :”jdk1.6/bin/java 120″ location of java installed folder, if installed java manually .

# alternatives –config java

Edit the basj profile:-
cd ~
vi .bash_profile

JAVA_HOME=/jdk1.6/bin/java
export PATH JAVA_HOME

source .bash_profile

Exit command
:wq!

Done .Verify

# java -version

# which java

Leave a Reply

Your email address will not be published. Required fields are marked *