⬅ Previous Topic
Install Java on Windows 10Next Topic ⮕
Install Java on macOS⬅ Previous Topic
Install Java on Windows 10Next Topic ⮕
Install Java on macOSThis tutorial will walk you through installing the Java Development Kit (JDK) on a Windows 11 machine.
Visit the official Oracle website to download the latest version of the JDK:
https://www.oracle.com/java/technologies/javase-downloads.html
Choose the version labeled “Windows x64 Installer” under the latest Java SE version. Click to download the .exe
installer file.
Java is now installed, but we still need to configure it so your system knows how to find Java tools.
To make Java accessible from the command line, you need to add it to your system's environment variables:
Path
, then click Edit.bin
folder inside your JDK installation. (e.g., C:\Program Files\Java\jdk-21\bin
)Open Command Prompt and type the following commands:
java -version
java version "21.0.1" 2024-10-17 LTS
Java(TM) SE Runtime Environment (build 21.0.1+12-LTS-123)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.1+12-LTS-123, mixed mode)
javac -version
javac 21.0.1
If you see version numbers instead of errors, congratulations! Java is successfully installed and configured.
Let’s test your Java setup by writing a simple program.
Create a file called HelloWorld.java
using any text editor (like Notepad).
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Java is successfully installed!");
}
}
Open Command Prompt in the directory where your HelloWorld.java
file is saved and run:
javac HelloWorld.java
This command compiles your Java code. If successful, it will generate a HelloWorld.class
file (the bytecode).
Now run the compiled program:
java HelloWorld
Java is successfully installed!
Perfect! You’ve just written and executed your first Java program.
java
or javac
is not recognized, recheck your Path
environment variable.⬅ Previous Topic
Install Java on Windows 10Next Topic ⮕
Install Java on macOSYou can support this website with a contribution of your choice.
When making a contribution, mention your name, and programguru.org in the message. Your name shall be displayed in the sponsors list.