Java source code is compiled by javac into bytecode (.class). The JVM runs that bytecode on any operating system, which makes Java platform independent.
JDK contains the JRE, the JRE contains the JVM
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
// javac Hello.java → Hello.class
// java Hello → runs on the JVM
Q & A
-
Why is main public static void?public: the JVM must call it from outside. static: it runs without creating an object. void: it returns nothing to the JVM.
-
Is Java fully object oriented?Not 100%, because it has primitive types (int, char, ...) and static members.