How to install Java (JDK) on Windows and Linux

For any Java program to work, you must install the Java virtual machine. Java has open source and is free.

What is the difference between Oracle JDK and OpenJDK

Java (more precisely JDK) has two main types:

  • Oracle JDK
  • Openjdk

In fact, at the moment this is approximately the same things, they differ mainly in licenses, release and support schedules – for us, end users, it does not make much difference which one to install. Moreover, OpenJDK is also currently being created by Oracle. OpenJDK is present in standard Linux repositories (although you can install JDK by downloading the installer from the official Oracle site).

In general, select any JDK from one of the following links:

If you are an advanced user, and know about the existence of the JRE, then this information is for you: the JDK already contains (and always contains the JRE) and now, apparently, the JREs are not created separately. But in the repositories of some distributions you can find separately the JDK and JRE packages. The JRE package takes up a little less space – if this is important for you, then install the JRE. If you plan to program or compile in Java, then you need a JDK.

How to install Java (JDK) on Windows

Download the installation file for Windows from one of the links provided and complete the installation as usual.

When installing the JDK, select the “Set JAVA_HOME variable” option:

How to install Java (JDK) on Linux

How to install OpenJDK

In Debian, Linux Mint, Kali Linux, Ubuntu and their derivatives, the installation is done like this:

sudo apt install default-jdk

On Arch Linux, BlackArch, and derivatives to install, run the command:

sudo pacman -S jdk-openjdk

In Arch Linux / BlackArch with archlinux-java program you can choose the default version of Java in Arch Linux.

archlinux-java <COMMAND>

COMMAND:

	status		List installed Java environments and enabled one
	get		Return the short name of the Java environment set as default
	set <JAVA_ENV>	Force <JAVA_ENV> as default
	unset		Unset current default Java environment
	fix		Fix an invalid/broken default Java environment configuration

How to install Oracle JDK

In Debian, Linux Mint, Kali Linux, Ubuntu and their derivatives, the installation is done like this:

Go to https://www.oracle.com/java/technologies/javase-downloads.html

Choose the version that suits you and download the file with the extension .deb.

Install this file:

sudo apt install ./jdk-*.bin.deb

For instance:

sudo apt install ./jdk-14.0.1_linux-x64_bin.deb

On Arch Linux, BlackArch, and derivatives for installation, install the pikaur command, as shown in the article “Automatic installation and update of AUR packages”.

Then run the command:

pikaur -S jdk

Last Updated on

Recommended for you:

Leave a Reply

Your email address will not be published.