- On
- By
- 0 Comment
- Categories: Basic, Java basic
How does JVM works internally in Java language
How does JVM works internally in Java language
In this tutorial, We will learn about How JVM works internally in Java language.
A program written in a high-level language is known as a source program or source code.
A source program must be translated into machine code for execution as a computer cannot understand a source program.
The computer can only execute the code in binary form.
The translation can be done using another programming tool called an interpreter or compiler.
What is a compiler?
A compiler translates the entire source code into a machine code file or an intermediate code. Then, that file is executed.
What is interpreter
An interpreter reads a statement from source code, translates it to the machine code or virtual machine code and then executes it right away.
How does Java work?
First, we can write a Java program using Java language in a text editor. Java source code will be saved with the extension is – .java Then, we can use a Java compiler to compile the codes to get the Java bytecode. This Java bytecode can have the .class extension. Java bytecode is the modified version of the Java source code. And then we can pass this Java bytecode to Java virtual machine (JVM) which is an interpreter. It reads one statement at a time from this Java bytecode. Then, it converts that machine level code and executes that code. This is repeated until all codes are executed. Finally, an output is available after the execution of the program.
Execute of same codes in different platforms.
We can execute our code in windows, and also we can execute our code in mac or Linux or other o/s.
how it is possible?
Java contains a special package JVM(Java virtual machine) which executes our Java bytecode. Java provides the specific platform for JVM. If you use windows platform, then you must have windows specific JVM. If you have used Linux platform, then you must have Linux specific JVM. All these platform-specific JVM are capable of executing the Java bytecode in the same way. So Java program is capable of running on different platforms.
Suggested for you
Feature of Java programming language