Monday 16 March 2015

Installing JAVA 7 (JDK 7u75) on a Linux machine

Installing java on a linux machine is very simple but you can mess it up, if not done properly.

Follow the steps below:

Step 1: Download the tar.gz packages using the below links:
--------------
64 bit
--------------
cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz"
---------------

-------
32 bit
-------
# cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-i586.tar.gz"
--------

Step 2: Unpack the jdk pacjages using the below command:
------
tar -xzf jdk-7u75-linux-x64.tar.gz
------

Step 3: Install Java with Alternatives
---------
Now, we need to set up the newer version of Java using alternatives. Run the below commands:

-------
#cd /opt/jdk1.7.0_75/
#alternatives --install /usr/bin/java java /opt/jdk1.7.0_75/bin/java 2
#alternatives --config java
--------

On running the command "alternatives --config java", you will receive the following output. Select the option  "3" to get the desired path.



Step 4: Now you may also required to set up javac and jar commands path using alternatives command.
----------
# alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_75/bin/jar 2
# alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_75/bin/javac 2
# alternatives --set jar /opt/jdk1.7.0_75/bin/jar
# alternatives --set javac /opt/jdk1.7.0_75/bin/javac
-----------

Step 5: Most of the java applications will work only if environment variables are set. For that, add the following variables to ~/.bashrc .

Just vi the file "~/.bashrc " and add entries as below:

Setup JAVA_HOME Variable
-------
export JAVA_HOME=/opt/jdk1.7.0_75
-------


Setup JRE_HOME Variable
--------
export JRE_HOME=/opt/jdk1.7.0_75/jre
--------


Setup PATH Variable
-------
export PATH=$PATH:/opt/jdk1.7.0_75/bin:/opt/jdk1.7.0_75/jre/bin
-------


Now, you are done. Just check the java version as below:



Done :)

No comments:

Post a Comment

Note: only a member of this blog may post a comment.