How To Install Java 11 On Windows

By bhagwatchouhan
How To Install Java 11 On Windows

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 an 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 with JDK in version 11, as it was available until version 10. We need to install the JRE separately if necessary.

 

Step 1: Download JDK

Open the browser and search for "Download JDK 11" or click the link to download from the Oracle website. The JDK download page will appear, as shown in Figure 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 changes. If required, we can also change the installation location on this screen, as shown in Fig 4.

Install Location

Fig 4

Now click on the 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 system does not detect the installed JDK. To do so, follow these steps.

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 the System Variables section, and click on Edit. We need to add the path of the installed JDK to the 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.

 

Share this blog:

Profile picture for user bhagwatchouhan
bhagwatchouhan