Image of How to setup java on unix


Table of Contents


This is a step-by-step guide to install java (JRE) on unix machine.

Step-1 Download Java

Download the appropriate tar.gz JRE package from oracle, choose the package which suits your system specifications (x86 for 32 bits) (x64 for 64 bits) and copy it to your user directory .i.e. /home/PG

Linux setup

P.S: if you install x86 version on 64 bit environment, java may not consume the dedicated amount of memory, it happened to me one day, when i installed java x86 on 64 bit environment by mistake and i kept hours investigating why java is not consuming the 2 GB memory which i assign to it.

Step-2 Install Java

Create a new directory named java under /usr/local then move the downloaded package to /usr/local/java and extract it there.

[PG@localhost ~]$ cd /usr/local
[PG@localhost local]$ mkdir java
[PG@localhost local]$ cd java
[PG@localhost java]$ mv /home/PG/jre-8u131-linux-x64.tar.gz /usr/local/java
[PG@localhost java]$ tar zxvf jre-8u131-linux-x64.tar.gz

Now java is installed successfully under /usr/local/java/jre1.8.0_73.

Step-3 Configure JAVA_HOME

The final step is to define the JAVA_HOME environment variable which is used by unix in order to run java applications.

Use the following commands:

[PG@localhost]$ export JAVA_HOME=/usr/local/java/jre1.8.0_73
[PG@localhost]$ export PATH=$PATH:$JAVA_HOME

In order to make sure that java is installed correctly, type java -version command which displays the currently active version of java:

[PG@localhost]$ java -version
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)

That’s it.


This is a step-by-step guide to install java (JRE) on unix machine.

Next Steps

If you're interested in learning more about the basics of Java, coding, and software development, check out our Coding Essentials Guidebook for Developers, where we cover the essential languages, concepts, and tools that you'll need to become a professional developer.

Thanks and happy coding! We hope you enjoyed this article. If you have any questions or comments, feel free to reach out to

Final Notes