One of the features of Java is platform independent. It achieves platform Independence through bytecode generation. Let us compile a simple Java program to see how bytecode looks.
Following is the example code to see the bytecode that prints "Hello World".
public class Demo
public static void main(String args)
Do not alter the bytecode, and if altered, the JVM throws exception.
This byte code generated at compile time is not known to the OS and the Microprocessor to execute later to get output. This byte code is to be converted back to binary code compatible to Microprocessor. This is done by JVM (Java Virtual Machine). The binary code generated in platform dependent. That is, the same byte code is converted to different formats of binary code by JVM as per underlying platform (OS).
JDK comes with two main components – Compiler and JVM. Other components are byte code verifier, class loaders, Garbage collector etc.