How To Java Path In Linux

Setting up the path for Java or any other programming languages is an essential step in the configuration process. It allows the system to know the exact location where the executables are stored. This post will guide you on how to set up the Java path in a Linux operating system.

Step 1: Download and Install Java

Before setting up the Java path, make sure that you have Java installed on your Linux system. If not, you can download it from the official website of Oracle. The installation process is straightforward and user-friendly. To check if Java is installed, open your terminal and type the following command:

java -version

You should see something like this if Java is successfully installed:

java version “1.8.0_91”
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

Step 2: Find the Java Installation Path

You’ll need to find out where Java has been installed. You can do this using the update-alternatives command in a terminal window.

update-alternatives –config java

This will output the path where Java is installed.

Step 3: Setting Up the Java Environment Variable

Now that you have your Java path, all you need to do is set it up as an environment variable in your system. This can be done by editing the .bashrc file in your home directory and adding the following lines at the end of the file:

        export JAVA_HOME=/usr/lib/jvm/java-8-oracle
        export PATH=$PATH:$JAVA_HOME/bin

Make sure that the location after JAVA_HOME= is the path where your Java is installed. Save and exit the file.

Step 4: Verify Your Configuration

After setting the Java path, it’s important to verify that the configuration has been done correctly. You can do this by typing the following commands in your terminal:

java -version

If everything is set correctly, it should output the path you set for JAVA_HOME and the Java version respectively.


In this blog post, we have covered how you can set Java path in Linux. This is an important step in setting up your Java development environment. Remember that the correct path may vary based on the version of Java and the Linux distribution you are using.