본문 바로가기

Linux

How to set JAVA_HOME environment variable in Ubuntu

How to set JAVA_HOME environment variable in Ubuntu

April 30, 2012

Setting the JAVA_HOME variable can be done in several ways.

1. Globally and at System level, i.e. no user is required to be logged in. This is the preferred way if you are configuring a server and planning to use boot strapped program that needs JAVA_HOME variable.

1/etc/environment
2JAVA_HOME=/usr/lib/jvm/java-7-oracle
2. Globally and set for all logged in user, i.e. one user is needed to be logged in, to have the JAVA_HOME variable set.
1/etc/bash.bashrc
3. User specific. Then the variable is only set when the designated user is logged in.
1/home/$USER/bash.bashrc


If you have different installed JDK you might find this blog useful on how to manage different JDK on Ubunut http://magnus-k-karlsson.blogspot.se/2012/03/managing-multiple-java-installation-on.html.