How To Set Java Path In Linux?

How to set java path in Linux?

Ans : Check where java is installed by using below command

#update-alternatives --config java
This command will show installed java packages in your machine.

Example output :
# update-alternatives --config java

There are 2 programs which provide 'java'.

Selection ----------------------------------------------- 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java *+ 2
From above you can see java version in use it. 1.6.

Setting java path(In Temporary way)

#JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk #export $JAVA_HOME

Setting java path (In Permanent way)
Edit ~/.bashrc and place below two lines in that file and save the file.

Vi ~/.bashrc
JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk export $JAVA_HOME

Now save the file and exit, then logout and login to make those changes to reflect.



  • Like the post? Please Subscribe to free RSS feed to get updates
  • Related Posts by Categories



    Translate this page


    The Linux Juggernaut | Copyright 2006-2009 Surendra Kumar Anne | Surendra's Home Page | Give us feedback how we are doing, Click here