Core Java

How to download Java 12 for Windows

In this article, we will see how to download and install java 12 jdk, which is a non-LTS version for a Windows system.

1. Introduction

The first version of Java came out in 1996 and since then has become one of the most widely used object-oriented programming languages. The most recent version of Java is 15 with Java 16 in the works. In this article, we will download and install java 12 jdk.

2. What is non-LTS version?

Starting Java version 8, Oracle shifted its release timeline and also the licenses.

2.1 License and release cadence changes

Prior to Java 8, Oracle released a new version every 2-3 years. Starting Java 8, Oracle has shifted to a 6-month release cadence.

Developers who prefer rapid innovation, so that they can leverage new features in production as soon as possible, can use the most recent feature release or an update release thereof and move on to the next one when it ships.


Matt Reinhold, chief architect for Java

To enable organizations to handle these changes, Oracle has declared that the versions (roughly 3 years apart) will be Long-Term support versions.

Long Term versions mean that organizations/individuals who have a paid commercial subscription with Oracle will receive support for nearly 8 years or more. Example: Java 11 was released in Sept 2018 and will receive support until 2026.

Java 17 is the next LTS version. All the versions in between are non-LTS versions. Oracle recommends updating to the next version as soon as it’s released. Oracle does not provide extended support for Non-LTS versions.

2.2 License Changes

Besides shifting the release cadence, Oracle has shifted from Binary Code License (BCL) to two licenses.

  • GNU General Public License v2 with Classpath exception (GPLv2+CPE) which is provided by OpenJDK builds.
  • The commercial license under Oracle product or service i.e. Oracle Technology Network License Agreement (ONTLA). Users can still this version for free if they use it for personal use. For Production use, the organizations will need to pay for “Java SE subscriptions”.

3. System Requirements

Post-Java 9, Java only supports 64-bit architecture on the Windows system. Visit the System Configuration page for more details.

4. Download and Install Java JDK 12

Since Java is available under 2 licenses, we can download Java from either Oracle JDK or OpenJDK.

4.1 Download and Install Oracle JDK 12

The Oracle jdk is available under the ONTLA license.

4.1.1 Download Oracle JDK 12

  • To download Oracle JDK 12, visit the Oracle Archive Downloads page.
  • Scroll down to locate the Java 12 and click on the executable. You need to accept the license agreement and login to the Oracle site. If you do not have an account, creating an Oracle account is free of cost.
  • The file that gets downloaded is jdk-12.0.2_windows-x64_bin.exe.
Java 12 - Oracle Archive download Page
Oracle Archive download Page

4.1.2 Install Oracle JDK 12

  • Click on the executable and follow the instructions for installing.
  • To set the PATH variable, open the Command Prompt (cmd) in Admin mode and write

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

Java 12 - setting PATH for Oracle JDK
setting PATH for Oracle JDK

4.2 Download and Install OpenJDK JDK 12

The Oracle jdk is available under the GPLv2+CPE license.

4.2.1 Download OpenJDK JDK 12

  • To download OpenJDK JDK 12, go the OpenJDK Archive Downloads page.
  • Scroll down to Java 12 and click on the .zip file for Windows.
  • The file that is downloaded is openjdk-12.0.2_windows-x64_bin.
Java 12 - OpenJDK Downloads Page
OpenJDK Downloads Page

4.2.2 Install OpenJDK JDK 12

  • To Install just extract the .zip to the folder of your choice.
  • Set the PATH variable for Java to run it from anywhere on the system.
  • To set the PATH, open the Command Prompt(cmd) in the Administrator mode and write

setx path “%PATH%; D:\Java\openjdk-12.0.2_windows-x64_bin\jdk-12.0.2\bin”

setting PATH for OpenJDK 12
setting PATH for OpenJDK 12

5. Checking the installation

To check the installation, there are 2 methods. One way is the command java -version and the other is where command. The PATH needs to be set for both methods to work.

5.1 java -version command

In the Command prompt type the command

java -version

If the PATH is set correctly the out put is like the below image.

Oracle JDK version command output
Oracle JDK version command output

OR

OpenJDK version command output
OpenJDK version command output

5.2 where command

If the PATH variable is set correctly, the “where” command will give the path to where the java executables are present. Open a command prompt and type

where java

Where command output
Where command output

6. Run Java 12

To check if the java is installed and running correctly, we will compile and run a simple Java program called FindtheSeason.java

FindtheSeason.java uses a feature of the switch statement introduced in Java 12 as a preview feature and outputs the season based on the month provided. More details about the Java Preview features is given on the Java Language Updates page.

FindTheSeason.java

public class FindTheSeason {

    public static enum Months {
        JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
    }

    private static String whatIsTheSeason(Months month) {
            String result = switch (month) {
                case MAR, APR, MAY -> "Spring";
                case JUN,JUL,AUG -> "Summer";
                case SEP,OCT,NOV -> "Autumn";
                case DEC,JAN,FEB -> "Winter";
                default -> "Invalid Month entered: " +String.valueOf(month) ;
            };
        return result;
    }

    public static void main(String[] args) {
        String currentMonth = args[0];
		
		System.out.println("");

        System.out.println(
        		"The Season for the month " + currentMonth + " is: " + whatIsTheSeason(Months.valueOf(currentMonth)));
    }

}

To compile and run preview features of a languages, we use the following commands

Compile: javac --release 12 --enable-preview FindTheSeason.java

Run: java --enable-preview FindTheSeason DEC

(Note: DEC is an argument passed to the program, not a part of the java run syntax in general.)

The outputs with various inputs is as shown in the image below

Java program compilation output
Java program compilation output
Java program run outputs
Java program run outputs

This means that Java 12 is installed correctly on our system.

7. Summary

The general opinion in the Java Developer community on upgrading to Java 12 is that developers should update to Java 12 on their systems and test their applications for compatibility with the newer features. This would greatly help transition our products/software to the next version when the next version is released.

However, IT is not a good idea to put Java 12 in production since it is non-LTS version and does not get extended support from Oracle.

8. Download the source code

Download
You can download the full source code of this example here: How to download Java 12 for Windows

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
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button