Java Linux

Java-home is a path or an environment variable. It is a path variable in Windows language and environment variable in Unix language. Environment variables are cords that encompass data such as file name, path or drive. It usually shows the directory where the JRE (Java Runtime Environment) is installed on your system or computer. General function is just to display the location where the java has been installed.

RECOMMENDED: How to Use Ubuntu: A Must Read for Beginners

Path variable on the other hand is used for searching for an application in the local file system in your computer. In short the path environment variable is used in maintaining a record of directories for executable programs search.

There are several methods of setting up the java-home variable. One can use either Synaptic Package Manager or apt-get commands.

Step 1. Install JDK and JRE

In our case we are using the apt-get. Let’s start by making JRE or JDK a default installation. This is usually endorsed because it is the simplest alternative. After installing JDK/JRE, openJDK6 will be installed on Ubuntu 12.04 and Ubuntu version that is 12.10+ will install open JDK7. For this, just follow the tutorials from this link: How To Install Java JRE and JDK on Ubuntu with Apt-Get

RECOMMENDED: Install Java Run-Time and Browser Java Plugin on Linux

Step 2. Setiing JAVA_HOME for Java

  1. Now to set JAVA_HOME for Java. You should set your JAVA_Home in /etc/environment. For this open the terminal and use nano or gedit text editor to open /etc/environment
  2. Now check the java path JAVA_HOME=”/usr/lib/jvm/open-jdk”  , pay attention as the Java path could be different.
  3. Use the source to load variable by running the following command in the terminal:
source /etc/environment

Step 3. Check JAVA_HOME Variable

Now you can check the variable by running the following command in the terminal:


This is how you can very simple and easy set the JAVA_HOME for Java on your Ubuntu Distro.

RELATED: How to define Java_Home variable in Windows XP


Leave a Reply