Python can execute raw code. This means it is a virtual machine that actively translate machine-independent python code into machine-dependent byte code in run time. Python choose to ship machine-independent human readable code, but Java choose to ship machine-independent bytecode for the following reasons: - bytecode is smaller than source code - bytecode is harder to reverse engineer than source code - bytecode is harder to modify than source code - JVM does not need to have a compiler (reduce footprint) - compile once, and run everywhere
Virtual Machine: a virtualization on CPU
Java Virtual Machine (JVM): parse Java's machine-independent byte code.
it as its own instruction sets in a .class
file
JVM execute bytecode in .class
file by translating them to machine code (you don't need JAVA to produce .class
file to feed JVM in theory)
exactly 1 instance of JVM will be paired with a Java program
Functionality of JVM
Java made the decision to ship machine-independent is to avoid re-compilation for different platforms. However, it requires the user to at least install machine-dependent
JRE
.
Java Runtime Environment: just a java virtual machine, used to run .class
bytecode
Java Development Kit: superset of JRE, including Java compiler, debugger, and many developing tool for debugging purposes.
Java provides Java Virtual Machine Specification and in theory you can make your own JVM. There are many JVMs in the market.
Table of Content