Java programs follow a two-step process: compilation and execution. Source code written by the programmer is first converted into bytecode, which is then executed by the Java Virtual Machine (JVM).
.java extensionjavac compiler.class filesjava commandThe Java compiler checks syntax errors and converts source code into platform-independent bytecode. This bytecode runs on any system that has a compatible JVM installed.
// Simple Java program to demonstrate compilation and execution
class HelloJava {
public static void main(String[] args) {
System.out.println("Java Compilation and Execution");
}
}
HelloJava.javajavac HelloJava.javajava HelloJavaOutput: Java Compilation and Execution