How Java Works (Write Once, Run Anywhere)
Java source code (.java) is compiled by the javac compiler into platform-independent Bytecode (.class). This bytecode is executed by the Java Virtual Machine (JVM).
Your First Java Program
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World from Java 21!");
}
}
Syntax Breakdown:
public class Main: Every line of executable code in Java must reside inside a class.public static void main(String[] args): The entry point method called by the JVM runtime.System.out.println(): Standard output stream method that prints text to the console with a trailing newline.