How to install Java and set JAVA_HOME permanently

1. Install Java

If you have already installed Java then skip to point 3.

Before continue make sure you don’t have installed Java.

Open terminal and invoke:

whereis java

command. If you do not have Java then you will see:

java:

That will mean you DONT have Java.

Download Java from here or use your package manager to install it.
2. Java location

By default Java is located in

/usr/lib/jvm/java-

directory.
3. Set $JAVA_HOME variable

To set JAVA_HOME only in actual shell session, invoke command:

export JAVA_HOME=/usr/lib/jvm/java-

To persist this environment variable edit vi ~/.bash_profile file, and add JAVA_HOME definition:

JAVA_HOME=/usr/lib/jvm/java-

Save and relogin to apply changes.

Leave a Reply

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

*