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.

### 4. Common Errors in installing JDK

SYMPTOM: Cannot compile Java program from the CMD shell (e.g., "javac Hello.java" does not work!)
ERROR MESSAGE: 'javac' is not recognized as an internal or external command, operable program or batch file.
PROBABLE CAUSES: The PATH environment variable, which maintains a list of search paths for executable
programs (including "javac.exe"), does not include JDK's bin directory.
POSSIBLE SOLUTIONS:
1) Start a CMD shell (click "Start" button ⇒ "run..." ⇒ enter "cmd") and issue a path command:
prompt> path
PATH=.......
2) Check if it includes your JDK's "bin" directory. For example, suppose that your JDK is installed
in "c:\program files\java\jdk-11.0.1", then PATH should include "c:\program files\java\jdk-11.0.1\bin".

Otherwise, include JDK's bin directory in the PATH environment variable.
Read "Step 3 of How to install JDK".

SYMPTOM: Can compile but cannot run Java program from the CMD shell (e.g., "java Hello" does not work!)
ERROR MESSAGE (Post JDK 1.7): Error: Could not find or load main class Xxx
ERROR MESSAGE (Pre JDK 1.7): Exception in thread "main" java.lang.NoClassDefFoundError: Xxx
PROBABLE CAUSES:
1) The Java class (in this example, Hello.class) is NOT in the current directory.
2) The CLASSPATH environment variable is set, but does not include the current directory ".".
POSSIBLE SOLUTIONS:
1) Issue a "dir" command to list the contents of the current directory.
Check that it contains the Java class to be run (e.g., Hello.class).
You need to compile the source program (".java") to get the class file (".class").
2) If the Java class is present in the current directory, issue a "set classpath" command
to check its settings:
prompt> set classpath
CLASSPATH=.......
If you receive the message "Environment variable CLASSPATH not defined" and
Otherwise, if the CLASSPATH is defined, for beginner, I suggest that you remove
the CLASSPATH environment variable.
From "Control Panel"
⇒ System
⇒ (Vista only) Advanced system settings
⇒ Environment Variables
⇒ System variables (and also User variables)
⇒ Select variable "CLASSPATH"
⇒ Delete (Delete from both the System variables and User variables)
3) (For Advanced Users Only) If CLASSPATH is not set, it is defaulted to the current directory.
However, if CLASSPATH is set, the current  directory is NOT implicitly included.
You can include the current  directory (denoted by a single dot ".") in front of the
existing class-paths.
Read "Java Applications and Environment Variable" for more discussion on CLASSPATH.

SYMPTOM: Can compile but cannot run the Hello-world program (e.g., "java Hello" does not work!)
ERROR MESSAGE (Post JDK 1.7): Error: Main method not found in class Hello.
POSSIBLE SOLUTIONS: Check whether there is a main() method in your program, and the signature of your main()
as shown in the error message.