JVM is the core of the Java Technology. A Java program can be run on any kind of machine which contains the JVM implementation. JVM is what makes Java platform independent.
How Java programs are Platform Independent?
- Upon compilation Java programs generate byte code instead of machine specific code. Byte code is compiled using JVM which generates the machine specific code. Java programs can be run any operating system which contains JVM.
- Initially .java programs are compiled by the JAVAC.EXE compiler into another .class file format which contains the byte code language corresponding to the .java.
- The .class file get is given another software Java Runtime Environment (JRE) which contains another software Java Virtual Machine (JVM) which checks the byte code using Code Verifier then passes to another compiler Just-in-time (JIT) compiler to create a binary on a machine.
- A number of things happens inside JVM like loading, linking and initialization. Go through the JVM section(JVM Link) to know more.
Following is the Java program execution workflow :
.java → JAVAC → .class → JVM(Class Loader → Code Verifier → JIT) → Binary Code → Execution
The primary goal of the Java project was to create a language that would be platform independence. Java Virtual Machine is the very foundation of the Java technology which makes it
JVM, Java Virtual Machine, is the specification for the Java runtime environment. JVM defines the lifecycle of a Java Program inside Java Runtime Environment.
Some of the constructs defined by the JVM
- Memory model
- Java program – creation, loading, verification, compilation, Byte code generation, interpretation of byte code, machine code generation, running the machine code
- Compiler , JIT Compiler