0% found this document useful (0 votes)
2 views

Java Virtual Machine

The Java Virtual Machine (JVM) is a virtual machine that executes Java byte code, enabling Java's platform independence. The javac compiler translates Java source code into byte code, which the JVM can understand, allowing the same byte code to run on different operating systems. This architecture ensures that Java programs can be written once and run anywhere, regardless of the underlying machine.

Uploaded by

Muwowo Kennedy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Java Virtual Machine

The Java Virtual Machine (JVM) is a virtual machine that executes Java byte code, enabling Java's platform independence. The javac compiler translates Java source code into byte code, which the JVM can understand, allowing the same byte code to run on different operating systems. This architecture ensures that Java programs can be written once and run anywhere, regardless of the underlying machine.

Uploaded by

Muwowo Kennedy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Java Virtual Machine (JVM),

Difference JDK, JRE & JVM – Core


Java
Java is a high level programming language. A program written in high level
language cannot be run on any machine directly. First, it needs to be translated
into that particular machine language. The javac compiler does this thing, it
takes java program (.java file containing source code) and translates it into
machine code (referred as byte code or .class file).

Java Virtual Machine (JVM) is a virtual machine that resides in the real machine
(your computer) and the machine language for JVM is byte code. This makes
it easier for compiler as it has to generate byte code for JVM rather than different
machine code for each type of machine. JVM executes the byte code generated
by compiler and produce output. JVM is the one that makes java platform
independent.

So, now we understood that the primary function of JVM is to execute the byte
code produced by compiler. Each operating system has different JVM,
however the output they produce after execution of byte code is same
across all operating systems. Which means that the byte code generated on
Windows can be run on Mac OS and vice versa. That is why we call java as
platform independent language. The same thing can be seen in the diagram
below:

So to summarise everything: The Java Virtual machine (JVM) is the virtual


machine that runs on actual machine (your computer) and executes Java byte
code. The JVM doesn’t understand Java source code, that’s why we need to
have javac compiler that compiles *.java files to obtain *.class files that contain
the byte codes understood by the JVM. JVM makes java portable (write once,
run anywhere). Each operating system has different JVM, however the output
they produce after execution of byte code is same across all operating systems.

You might also like