Java

Install Java 8 on Windows and Ubuntu

This tutorial will show how to install Java 8 on Windows and Ubuntu and the needed environment variables setup for application development.

Windows

Installation

Visit this link to download the appropriate JDK for your Windows (32 or 64 bits), accepting Oracle’s licence agreement.

Run the newly downloaded installer and proceed with the installation, accepting the licence terms and advancing the installation steps to complete the process, without additional settings.

Environment Variables

Open the environment variables settings window by pressing Windows + Pause/Break or through Control Panel -> System -> Advanced system settings -> Environment Variables.

Click on New… button on System environment variables and add the three following variables.

Variable nameVariable value
JAVA_HOMEJDK installation path, example: C:\Program Files\Java\jdk1.8.0_20
CLASSPATH. (just a dot)
PATHIt may already exists on your system under the name Path, so edit its value by adding at the end: %JAVA_HOME%\bin; If it not exists already, create a new one with the value %JAVA_HOME%\bin;

Validating

In order to validate the Java installation and variables setup, open the Command Prompt by clicking the Start Menu and type cmd. Type the following commands in the prompt, which should print the version information if Java has been configured correctly.

C:\Users\Bruno>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)
C:\Users\Bruno>javac -version
javac 1.8.0_25

Ubuntu

Installation

In Ubuntu terminal, add the repository where Java installation packages can be found:

sudo add-apt-repository ppa:webupd8team/java

Update the packages list with the newly added repository and install Java:

sudo apt-get update
sudo apt-get install oracle-java8-installer

During the installation process, you must confirm the Java download then accept the licence agreement. After the confirmations, wait until the installation is complete.

Environment Variables and Validation

The installation through the above steps often automatically performs the necessary settings for Java development on Ubuntu, then let’s validate the installation with the following commands:

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)
javac -version
javac 1.8.0_25

Hope it helps. Cya!

bgasparotto

View Comments

Recent Posts

Python function decorator

This guide will show you how to create a Python function decorator with a few…

2 years ago

Got permission denied while trying to connect to the Docker daemon socket

This guide will show you how to fix the error Got permission denied while trying…

2 years ago

Python virtual environment on Intellij IDEA

This guide will show you how to create a Python virtual environment on Intellij IDEA…

2 years ago

Find and kill processes on Linux and Mac by port number

This tutorial will quickly show you how to to find and kill processes on Linux,…

2 years ago

Python: Relocation R_X86_64_PC32 against symbol can not be used when making a shared object Error

This guide shows a possible solution for Python error Relocation R_X86_64_PC32 against symbol can not…

2 years ago

Kubernetes useful commands

I condensed below a cheat sheet of Kubernetes useful commands. I will keep updating this…

2 years ago