Sunday, June 11, 2017

Setting up Java in Linux Environment

JAVA installation in Linux

Majority of application servers and applications require Java . Here I am going to explain how to install JAVA in Linux environment. There are different vendors and different version of Java . You can get its details from Link. But here I am describing about Hotspot ( Oracle JDK ) 

1. Download JDK of required version from
    There will be files 2 kind of  extension  1) .rpm 2) .tar.gz download any one of it.
2. if downloaded file is with  .rpm  extension  use
         #rpm -ivh .rpm 
    if downloaded file is with .tar.gz extension
       #tat xvzf .tar.gz
             The above command will extract JDK .
   Next step is add JDK's  bin location in PATH variable.  suppose you have extracted JDK in to /opt/ directory and you got path like /opt/jdk1.8.0_56 then add following 2 lines  in /etc/profile ( just before  the line  "unset i " )
  export JAVA_HOME=/opt/jdk1.8.0_56/
export PATH=$PATH:/opt/jdk1.8.0_56/bin 

Just re-login ( or do the command   "source /etc/profile")  and type "java".

How to set default Java using alternative command

If we have downloaded and extracted multiple java in Linux system, we can make one version of Java as default

To add new java to the alternative list use following command

#sudo alternatives --install /usr/bin/java java  /opt/jdk1.8.0_56/bin/java 1000

To set new  Java as default   use following command
#alternatives --config java

Enter the number shown under "Selection" column corresponding to the Java which we want to set as default

Ensure the correct version has been set, by using command
#java -version 

Which operating system you like most?