Compiling and running a java program involves below steps :
- 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