Step 0: Un-Install Older Version 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 of JDK/JRE, un-install ALL of them. Goto "Control Panel" = "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
Goto Java SE download site @ http://www.oracle.com/technetwork/java/javase/downloads/index.html.
Under "Java Platform, Standard Edition" = "Java SE 10.0", where x denotes a fast running update number = Click the JDK's "Download" button.
Under "Java SE Development Kit 10.0.x" = Check "Accept License Agreement".
Choose the JDK for your operating system, i.e., "Windows" for 64-bit Windows OS, and download the installer e.g., "jdk-10.0_windows-x64_bin.exe" - 390MB.
Step 2: Install JDK and JRE
Run the downloaded installer e.g., "jdk-10.0.windows-x64_bin.exe", which installs both the JDK and JRE.
By default:
JDK is installed in directory "C:\Program Files\Java\jdk-10.0.x, where x denotes the upgrade number; and
JRE is installed in "C:\Program Files\Java\jre-10.0.x".
Notes: In 64-bit Windows, "Program Files" is meant for 64-bit programs; while "Program Files (x86)" for 32-bit programs.
Accept the defaults and follow the screen instructions to install JDK and JRE.
Use the "File Explorer", goto "C:\Program Files\Java" to inspect these folders. Take note of your JDK installed directory, in particular, the varying upgrade number, which you will need in the next step.
Step 3: Include JDK's "bin" Directory in the PATH
Windows' Shell 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 "bin" in the PATH to run the JDK programs.
To edit the PATH environment variable in Windows 7/8/10:
Launch "Control Panel" = Optional System and Security = System = Click "Advanced system settings" on the left pane.
Switch to "Advanced" tab = Push "Environment Variables" button.
Under "System Variables" (the bottom pane), scroll down to select "Path" = Click "Edit...".
For Windows 10 (newer releases):
You shall see a TABLE listing all the existing PATH entries if not, goto next step. Click "New" = Enter the JDK's "bin" directory "c:\Program Files\Java\jdk-10.0.{x}\bin" Replace x with your installation number! = Select "Move Up" to move this entry all the way to the TOP.
Prior to newer Windows 10:
In "Variable value" field, INSERT "c:\Program Files\Java\jdk-10.0.\\bin" IN FRONT of all the existing directories, followed by a semi-colon which separates 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-10.0\bin;
Notes: Starting from JDK 1.8, the installation created a directory "c:\ProgramData\Oracle\Java\javapath" and added to the PATH. It contains only JRE executables = java.exe, javaw.exe, and javaws.exe, but NOT the JDK executables \e.g., javac.exe.
// Display the JRE version
prompt: java -version
java version "10" 2018-04-17
Java(TM) SE Runtime Environment 18.3
Java HotSpot 64-Bit Server VM 18.3
// Display the JDK version
prompt= javac -version
javac 10.0