Tuesday 13 October 2015

Oracle Java Installation on Ubuntu



                                                         Java Installation
     
   Java installation is totally depends upon your preference , you can install it through command line or  you can downloade tar.gz from oracle site, I prefer second way, So I am explaining how to install java using tar.gz.


 1)- Download java from oracle site. my download directory is /media/amit.pathak/download
 http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html.

 2)- Copy java tar from download location to any standard location like I move it to /usr/local/java.

    sudo cp /media/amit.pathak/download/jdk-7u79-linux-x64.tar.gz  /usr/local/java

3)- Extract tar at same location
   
    a)- cd /usr/local/java
    b)- tar xvzf jdk-7u79-linux-x64.tar.gz

4)- Change user

  sudo chown amit.pathak:amit.pathak -R FOLDERNAME

5)- Open profile file to put java path
 
       sudo nano /etc/profile

    add below lines at file bottom

          JAVA_HOME=/usr/local/java/java7
          JRE_HOME=$JAVA_HOME/jre
          PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
          export JAVA_HOME
          export JRE_HOME
          export PATH

ctrl + x  --> hit Y --> hit Enter

6)- execute command -> source /etc/profile to load save data.

7)- Now it's turn to say ubuntu hi I want to use new java, you can execute below command

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.7.0_49/jre/bin/java" 0

0 - If you dont have any version of java already install on your machine
to check execute

sudo update-alternative --config java

it will list out all java flavor installed on your system.


Now you are done with your java installation, you can verify same by running command java or javac

No comments:

Post a Comment