javac HelloWorld.java # creates HelloWorld.class java HelloWorld # runs the program Expected output:
javac --version If you see version numbers for both, congratulations — you're ready to write Java! Create a file called HelloWorld.java :
java --version You should see something like:
openjdk 17.0.9 2023-10-17 OpenJDK Runtime Environment Temurin-17.0.9+9 OpenJDK 64-Bit Server VM Temurin-17.0.9+9 Then check the compiler:
public class HelloWorld public static void main(String[] args) System.out.println("Hello, Java!");
Compile and run it: