Downloading and Installing JDK

This page shows how to download and install the latest version of the Java Development Kit (JDK). Read the instructions carefully to set the "classpath" mentioned in Step 3. Once JDK has been installed, you can write a simple Java program using an editor such as notepad and run it from a command prompt. Alternatively, Java programs can be written using an Integrated Development Environment (IDE) such as NetBeans, described below.

1. JDK Versions

1.1. How To Install JDK on Windows: Steps 0-4

Step 0: Un-Install Older Version(s) of JDK/JRE

I recommend that you install only the latest JDK. Although you can install multiple versions of JDK/JRE concurrently, it is messy.

If you have previously installed older version(s) of JDK/JRE, un-install ALL of them. Goto "Control Panel" ⇒ (optional) "Programs" ⇒ "Programs and Features" ⇒ Un-install ALL programs begin with "Java", such as "Java SE Development Kit ...", "Java SE Runtime ...", "Java X Update ...", and etc.

 

Step 1: Download JDK

  1. Goto Java SE download site @ http://www.oracle.com/technetwork/java/javase/downloads/index.html.
  2. Under "Java Platform, Standard Edition" ⇒ "Java SE 11.0.{x}", where  {x} denotes a fast running security-update number ⇒ Click the "Oracle JDK" "Download" button.
  3. Under "Java SE Development Kit 11.0.{x}" ⇒ Check "Accept License Agreement".
  4. Choose the JDK for your operating system, i.e., "Windows". Download the "exe" installer (e.g., "jdk-11.0.{x}_windows-x64_bin.exe " - about 150MB).

 

Step 2: Install JDK

Run the downloaded installer (e.g., "jdk-11.0.{x}_windows-x64_bin.exe"), which installs both the JDK and JRE.

By default, JDK is installed in directory "C:\Program Files\Java\jdk-11.0.{x} ", where {x} denotes the update number. Accept the defaults and follow the screen instructions to install JDK.

Use your "File Explorer", navigate to "C:\Program Files\Java" to inspect the sub-directories. Take note of your JDK installed directory, in particular, the update number {x}, which you will need in the next step.

In the following diagram, the JDK installed directory is "C:\Program Files\Java\jdk-11.0.1", where {x}=1.

JDK_Path

I shall refer to the JDK installed directory as  <JAVA_HOME>, hereafter, in this article.

 

Step 3: Include JDK's "bin" Directory in the PATH

Windows' Command Prompt (CMD) searches the current directory and the directories listed in the  PATH environment variable (or  system variable) for executable programs. JDK's programs (such as Java compiler "javac.exe " and Java runtime "java.exe") reside in the sub-directory  "bin" of the JDK installed directory. You need to include JDK's " bin " in the PATH to run the JDK programs.

To edit the PATH environment variable in Windows 10:

  1. Launch "Control Panel" ⇒ (Optional) "System and Security" ⇒ "System" ⇒ Click "Advanced system settings" on the left pane.
  2. Switch to "Advanced" tab ⇒ Click "Environment Variables" button.
  3. Under "System Variables" (the bottom pane), scroll down to select variable "Path" ⇒ Click "Edit...".
  4. For Newer Windows 10:
    You shall see a TABLE listing all the existing PATH entries (if not, goto next step). Click "New" ⇒ Click "Browse" and navigate to your JDK's "bin " directory, i.e., "c:\Program Files\Java\jdk-11.0.{x}\bin ", where {x} is your installation update number ⇒ Select "Move Up" to move this entry all the way to the TOP.
    Skip the next step.
  5. For Older Windows 10:
    (CAUTION: Read this paragraph 3 times before doing this step! Don't push "Apply" or "OK" until you are 101% sure. There is no UNDO!!!)
    (To be SAFE, copy the content of the "Variable value" to Notepad before changing it!!!)
    In "Variable value" field, APPEND "c:\Program Files\Java\jdk-11.0.{x}\bin " (where {x} is your installation update number) IN FRONT of all the existing directories, followed by a semi-colon (; ) to separate the JDK's bin directory from the rest of the existing directories. DO NOT DELETE any existing entries; otherwise, some existing applications may not run.
Variable name  : PATH
Variable value : c:\Program Files\Java\jdk-11.0.{x}\bin;[do not delete exiting entries...]

 

Step 4: Verify the JDK Installation

LaunchCMD via one of the following means:

  1. Click "Search" button ⇒ Enter "cmd" ⇒ Choose "Command Prompt", or
  2. Right-click "Start" button ⇒ run... ⇒ enter "cmd", or
  3. Click "Start" button ⇒ Windows System ⇒ Cocmmand Prompt

Issue the following commands to verify your JDK installation:

  1. Issue "path" command to list the contents of the PATH  environment variable. Check to make sure that your JDK's "bin" is listed in the PATH.
    path
    PATH=c:\Program Files\Java\jdk-11.0.{x}\bin;[other entries...]
  2. Issue the following commands to verify that JDK/JRE are properly installed and display their version:
// Display the JDK version
javac -version
javac 11.0.1

// Display the JRE version
java -version
java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)