Install On Windows 10
Install On Windows 10
A school program needs reliable data and clear rules. Install a supported Windows JDK, configure its bin directory in PATH when needed and reopen the terminal. Verify java and javac before compiling a school program.
Understand
Install a supported Windows JDK, configure its bin directory in PATH when needed and reopen the terminal.
Apply
Trace the Java example, predict its output and explain the result before running it.
Avoid mistakes
Changing PATH does not update an already-open terminal. The JDK folder and its bin folder serve different configuration purposes.
Install Java on Windows 10
This tutorial will walk you through the steps for installation of Java on Windows 10.
Step 1: Download the Java JDK
Visit the official Oracle website: Download Java JDK.
Choose the appropriate version for your system — usually "Windows x64 Installer". Click "Download" and accept the license agreement if prompted.
Step 2: Run the Installer
Locate the downloaded .exe file and double-click to run it. The installation wizard will open.
- Click “Next” on the welcome screen.
- Choose an installation path (or leave the default).
- Click “Next” again to start the installation.
- Once the installation finishes, click “Close”.
Step 3: Set Environment Variables
To run Java from the command line, you’ll need to set the JAVA_HOME and PATH environment variables.
Set JAVA_HOME
- Open Control Panel → System and Security → System.
- Click on Advanced system settings.
- In the System Properties window, click on Environment Variables.
- Under “System Variables”, click New:
- Variable name:
JAVA_HOME - Variable value: Path to your JDK folder, e.g.,
C:\Program Files\Java\jdk-17
Update PATH Variable
- Still in Environment Variables, find the Path variable under "System Variables". Click Edit.
- Click New and add:
%JAVA_HOME%\bin - Click OK on all dialogs to save and exit.
Step 4: Verify Installation
Open Command Prompt and type:
java -version
java version "17.0.1"
Java(TM) SE Runtime Environment (build 17.0.1+12)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12, mixed mode)
If you see a version message like above, your installation was successful!
Step 5: Compile and Run a Java Program
Let’s try a sample program to make sure everything is working fine.
Write the Program
Open Notepad and paste the following:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Java is installed and working!");
}
}
Save it as HelloWorld.java in a folder of your choice.
Compile the Program
cd path\to\your\file
javac HelloWorld.java
If no error appears, it means the compilation is successful. A file named HelloWorld.class should be created.
Run the Program
java HelloWorld
Java is installed and working!
Common Issues and Fixes
- 'javac' is not recognized: Check that
%JAVA_HOME%\binis correctly added to thePATHvariable. - Wrong version showing: You may have multiple Java versions. Check your system PATH for older entries and remove them.
Conclusion
You’ve successfully installed Java on Windows 10 and run your first program!
Important boundaries and mistakes
Changing PATH does not update an already-open terminal. The JDK folder and its bin folder serve different configuration purposes.
Try the school example
Before running this Java program, write down each line you expect to see. Identify the value, branch, object or exception responsible for each line. Then explain whether the following assumption is valid: Changing PATH does not update an already-open terminal.
Java 17 · Main.java · complete practice program
public class Main {
public static void main(String[] args) {
System.out.println(System.getProperty("java.specification.version"));
}
}
Worked answer and reasoning
Java 17 · Main.java · source repeated for this answer
public class Main {
public static void main(String[] args) {
System.out.println(System.getProperty("java.specification.version"));
}
}
Expected output on the Java 17 teaching runtime; your installed version can differ
17Install a supported Windows JDK, configure its bin directory in PATH when needed and reopen the terminal. Verify java and javac before compiling a school program.
Changing PATH does not update an already-open terminal. The JDK folder and its bin folder serve different configuration purposes.
Run with javac Main.java, then java Main. The declaration of Main names the class; main starts the example, and println writes a complete output line.
Check your understanding
What to remember
Install a supported Windows JDK, configure its bin directory in PATH when needed and reopen the terminal. Verify java and javac before compiling a school program. Changing PATH does not update an already-open terminal. The JDK folder and its bin folder serve different configuration purposes.
Related explanations: Java Variables, Java If Statement - Syntax and Examples, Java Class - Blueprint of Objects, Exceptions in Java Introduction.
Supporting documentation: Official Java learning guide and Java 17 language specification.
Reaching the recap and completing the quizzes are separate milestones.