Java: Install Java

By Xah Lee. Date: . Last updated: .

Microsoft Windows and macOS

Download the Java JDK here: https://www.oracle.com/java/technologies/javase-downloads.html

(JDK means Java Developer's Kit)

Installing Java on Ubuntu

If you are on Unbuntu Linux, for example download jdk-8u25-linux-x64.tar.gz.

  1. Create a directory to put the java stuff there. For example, mkdir ~/apps
  2. Move the download tar file into the new directory. For example, mv ~/Downloads/jdk-8u25-linux-x64.tar.gz ~/apps
  3. Then cd to the directory. cd ~/apps
  4. Unpack it by: tar xvfz jdk-8u25-linux-x64.tar.gz

After unpacking, the most important directory is the bin dir. For example, on my machine i have:

Add Java's “bin” dir to your PATH environment variable. For example, put this in your ~/.bashrc:

# append java path to PATH
PATH=$HOME/apps/jdk1.8.0_25/bin:$PATH

Then, type . ~/.bashrc to reload the bash profile.

To test java, type java -version:

◆ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)