Where and How to set JAVA_HOME on OSX, Yosemite, Lion, Mountain Lion, Mavericks, El capitan, Ubuntu

How to set java_home on Windows?

Using /etc/environment file

If you want to set JAVA_HOME environment variables globally and at system level means use should set in /etc/environment file.

First open /etc/environment file and place following code anywhere of the file.

Here, [version] may changeable as per your Java Version. You can check like below commands,

After set the JAVA_HOME variable, you should update and execute in every shell using following code,

Using ~/.bashrc file


If you want to set JAVA_HOME environment variable in only the terminal, set it in ~/.bashrc file.

For Ubuntu, Open the ~/.bashrc file and put the below code at anywhere of the file,

Here, [version] may changeable as per your Java Version.

Based on Jilles van Gurp, for Java optional package with other OSX things, use following method in same file ~/.bashrc,

Here, -v flag based on Jilles van Gurp response and 1.8 / 1.7 are the versions of jdk.

How to set java_home environment variable in windows? See Here.

Where and How to set JAVA_HOME on OSX, Yosemite, Lion, Mountain Lion, Mavericks, El capitan, Ubuntu

Just share...Share on FacebookShare on Google+Tweet about this on TwitterPin on PinterestEmail this to someone
The following two tabs change content below.
I am Karthik, software engineer by profession. You can find and follow me, from Social Media or here. Google+

Latest posts by karsho (see all)

This entry was posted in General, Java, Ubuntu.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please Fill this Sum * Time limit is exhausted. Please reload the CAPTCHA.