How To Install Java 11 On Windows

How To Install Java 11 On Windows

It explains how to install Java 11 distributed by Oracle on Windows 10 and getting started with Java development using the Hello World example. The steps should be similar to install other versions of Java and Windows.

January 14, 2019

This tutorial provides all the steps required to install the LTS version of Java i.e. Oracle Java 11 officially distributed by Oracle for Window. It provides the steps required to install Java 11 on Windows 10. The steps should be the same for other versions of Windows operating system.

We suggest removing existing versions of Java unless and the otherwise older version is explicitly required for any other software like Android Studio. We can check the currently installed and active JDK on the console as mentioned in Fig 1.

Java Version Check

Fig. 1

We must note that the JRE won't be bundled together with JDK in version 11 as it was available till version 10. We need to install JRE separately if required.

Step 1 - Download JDK

Open the browser and search for Download JDK 11 or click the link to download from Oracle website. It will show the JDK download page as shown in Fig 2.

Download Java 11

Fig. 2

Accept the License Agreement and click on the link to download the installer as highlighted in Fig 2 a and Fig 2 b. It will start downloading JDK 11 installer for Windows.

Accept License Agreement

Fig 2 a

Download Java 11

Fig 2 b

Step 2 - Install JDK

Now execute the downloaded JDK installer by double-clicking it. It might ask system permission before starting the installation. Click on yes to allow the installer to execute itself. It shows the installer welcome screen as displayed in Fig 3.

Welcome Screen

Fig 3

Click on Next to initiate the installation process. The next screen shows options to select optional features to be installed together. Leave the default options without making any change. We can also change the installation location on this screen if required as displayed in Fig 4.

Install Location

Fig 4

Now click on Next Button to start the installation. It will show the progress as displayed in Fig 5.

Installation Progress

Fig 5

It shows the success screen after completing the installation as mentioned in Fig 6.

Installation Success

Fig 6

Now open the Command Prompt and type the command java -version to confirm whether it's installed successfully as mentioned in Fig 7.

Version Check

Fig. 7

We might need to set the environment variable in case the installed JDK is not detected by the system. You can follow the below-mentioned steps to set the environment variable.

Right Click -> My Computer(This PC) -> Properties -> Advbanced System Settings

The above steps will open the Windows settings panel as shown in Fig 7.

Advanced Settings

Fig 7

Now click on Environment Variables, select Path under System Variables section and click on Edit. We need to add the path of installed JDK to system Path.

Click on New Button and add the path to installed JDK bin which is C:\java\java-11\jdk-11.0.1\bin in our case. Press OK Button 3 times to close all the windows. This sets the JDK 11 on system environment variables to access the same from the console.

Now again open the console and test the Java version as shown in Fig 8.

Confirm Path

Fig 8

Getting started with Java - Hello World

In this step, we will write, compile, and execute our first program in Java using the standard Hello World example.

Now write the first Java program as shown below, save the program as HelloWorld.java and exit the editor. Make sure that the class name and file name are the same.

class HelloWorld {

public static void main( String[] args ) {

System.out.println( "Hello World !!\n" );
}
}

Now open the command prompt and navigate to the path where you have saved your Java program. Use the below-mentioned commands to compile and execute the program.

# Compile - Specify file name and extension
javac HelloWorld.java

# Execute - Spicy file name
java HelloWorld

# Output
Hello World !!

Summary

These are the easy to install steps required to install Oracle Java on Windows and write, compile and execute the Java program.

Write a Comment
Click the captcha image to get new code.
Discussion Forum by DISQUS