Core Java

How to Download and Install Java 15

This article shows how to download and install Java 15, a non-LTS version for a Windows system.

1. Introduction

Java’s first version released in 1996. Java is now the most popular object-oriented programming language. The most recent version of java is 16, with Java 17 in the works. In this article, we download and install Java 15, which is a Non-LTS version.

2. Download and install Java JDK 15

Depending upon the license you want to choose, there are 2 places where we can download java. Oracle JDK is the enterprise version, and the OpenJDK is the open-source version. We look at how to download and install Java JDK 15 from both.

2.1 Oracle JDK

The Oracle JDK is available under the Oracle Technology Network License Agreement (ONTLA) license. The Oracle JDK has a commercial version(Users and organizations can buy a subscription to get support from Oracle for the Java installation).

2.1.1 Download

Java JDK 16 has now superseded Java 15. Hence to download Java 15, we need to go to the Java SE 15 Archive Downloads page.

  • On the Archive-Downloads page, scroll down to find the Windows x64 Installer and click on the executable file to download.
  • You need to log into Oracle and need to accept the license agreement
  • If you do not have an account, creating one is a simple and free-of-cost process. The file that gets downloaded is jdk-15.0.2_windows-x64_bin.exe.
java 15 download - Oracle JDK
Oracle JDK

2.1.2 Install

To install java, click on the executable jdk-15.0.2_windows-x64_bin.exe that gets downloaded on your system and follows the steps in the executable.

2.2 OpenJDK

The OpenJDK JDK is available under the GPLv2+CPE license and is the open-source version. Oracle does not provide commercial (subscription-based) support for the OpenJDK java distributions.

2.2.1 Download

The latest version of Java is Java 15, and so to download, we need to navigate to the Archived Release page. Scroll down to the 15.0.2 build and click on the zip file for Windows. The file that gets downloaded is openjdk-15.0.2_windows-x64_bin.zip.

OpenJDK Java 15 download
OpenJDK Java 15 download

2.2.2 Install

To install the JDK, extract the .zip file in the folder of your choice.

3. Setting the PATH variable

After java installs, it is advisable to set the PATH variable with the path to the Java executables. Doing so enables the system to recognize java. There are 2 steps to set the path variable.

3.1 Command Prompt(cmd)

To set the PATH variable using cmd, Open cmd in the “Administrator” mode. Type the following commands and hit Enter.

For Oracle JDK:

 setx path “%PATH%; C:\Program Files\Java\jdk-15.0.2\bin” 

Open JDK: (path to the oracle jdk extracted folder)

 setx path "%PATH%; D:\OpenJDKBuilds\openjdk-15.0.2_windows-x64_bin\jdk-15.0.2\bin" 

3.2 Environmental variables

We can also set the path variable by using the environmental variables dialog.

  • In the “Type here to search” box, Type in environment variables.
  • Click on the first option, which opens the System variables screen.
  • Click on the Environment variables button. Clicking opens the environment variables dialog box.
  • Click on the PATH variables and then click on the Edit button.
  • In the dialog box that opens, put in the Java executable path and then click on OK.
OpenJDK environmental variable
OpenJDK environmental variable
java 15 download - Oracle JDK environmental variable
Oracle JDK environmental variable

4. Verifying the installation

There are 3 ways to verify that we have installed Java correctly.

4.1 Using the java -version command

If we have installed java correctly and set the PATH correctly, the java -version command should output the java JDK information and the java version. The command is

 java -version
java 15 download - Java version output
Java version output

4.2 where command

If we have installed java and set the PATH correctly, the where command outputs all the java executables present on the system.

 where java 
java 15 download - where output
Where output

4.3 Checking the installed folders/files

Alternatively, we can also check the installed files/folders

4.3.1 Oracle JDK

For the Oracle JDK installation, type “Programs” in the Type search box and select the first option. This step opens the “Apps and Features” dialog box. In the search box, type in java, which should output the Java version we just installed.

4.3.2 OpenJDK

For the Open JDK, navigate to the extracted folder. Check if there is a bin folder with the java executables in it.

java 15 download - Java installation files
Java installation files

5. Example Program

To ensure that Java 15 is installed and running correctly, we compile and run a program that uses one of the preview features of Java 15 called Sealed classes implemented in JEP 360. Learn more about JEP 360 here. Using sealed classes, the classes can control which classes can inherit and which cannot.

We have an interface called Birds.java. We also implement three record classes(which is also one of the features enhanced in Java 15): Parrots, Ducks, and Ostrich. However, The Birds interface permits only the Parrots and Ducks to implement it. The Ostrich record is not allowed to implement the sealed interface. Hence if Ostrich implements the Birds interface, Java throws an IncompatibleClassChangeError. However, Parrots implementing the Birds interface works just fine. The fact that this Program works with our Java setup means that Java version 15 is installed and working correctly. Given below is the code for the Birds interface and the Ostrich and Parrots record class.

Birds.java

package com.jcg.examples;
public sealed interface Birds permits Ducks,Parrots{    
}

Parrots.java

package com.jcg.examples;
public final record Ostrich(int numFeathers) implements Birds{
  ///some logic
}

Ostrich.java

package com.jcg.examples;
public final record Parrots(int numSpecies) implements Birds{
  ///some logic
}
java 15 download - Program output
Program output

6. Summary

The general opinion in the Java Developer community on upgrading to Java 15 is that developers should update to Java 15 on their systems and test their applications for compatibility with the newer features. This step would greatly help transition to the next version when the next version is released. It is, however, not a good idea to put Java 15 in production since it is a non-LTS version.

8. Download the Source Code

Above was a tutorial on how to download and install Java 15 for a Windows operating system.

Download
You can download the full source code of this example here: How to Download and Install Java 15

Reshma Sathe

I am a recent Master of Computer Science degree graduate from the University Of Illinois at Urbana-Champaign.I have previously worked as a Software Engineer with projects ranging from production support to programming and software engineering.I am currently working on self-driven projects in Java, Python and Angular and also exploring other frontend and backend technologies.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button