Java Virtual Machine and Bytecode
Today we will try to understand two common terms, which will be helpful to you if you are new into the Java Field – the Java Virtual Machine ( also abbreviated as JVM) and Bytecode. Carefully take a look at the figure below.
When you start writing codes – it is in Java and the source code is shown on the top left hand side in the above diagram. Once you write the code, the Java compiler compiles it to produce bytecode. The Bytecode is then input to the Java Virtual Machine. The JVM or the Java Virtual Machine is what gives Java machine independency. The JVM will produce a machine code that is intended only for the machine on which it is intended to run. In this way same code can be used on different machines.
Here are the steps of Java development compile and run
# The source code is written in Java and is stored as .java files
# The jaba files are compiled by the Java compiler which produces the Bytecode. The Bytecode is stored as .class files.
# The Java Virtual Machine takes in the .class file and produces the machine code. The machine code runs on the target platform.