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%\bin
is correctly added to thePATH
variable. - 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!