``` How and what is happening behind the scene while using java what is the role of jvm in java ๐๐๐๐ ```
## Java Virtual Machine (JVM) The software equivalent of a computer on which Java programs run.
## JVM(Java Virtual Machine)** which provides a runtime environment to the user to interact with the user actions which is given in the form of program. Practically JVM set a platform for the user to interact with hardware and software which comes in touch with operating system. Here the byte code had been provided internally which makes the connection between compiler to read the program written in any language and provide the possible outcome as per the source code.
Some key points we should know :-
When we double click a file, it loads into ram from the hard disk for execution. The file is called process in RAM.
We load the code in RAM because we want to run the file by some other device known as CPU. CPU is designed in such a way that it will read the file instruction from RAM(Main memory).
If you write your code that directly run on your devices then this type of programming is called low level programming.
CPU understands machine language and we cannot write machine level language because it is complex and it is per processor meaning it changes with every other company Processor. So we write our code in a language that gets converted into MLL and can be executed on every other CPU.
To convert high level language into machine code we need a translator called compiler.
The bigger problem arises after compilation in high level language like C and C++ is that if we send the compiled file written in machine code to some other person, working on different computer, having different processor from mine, the processor will fail to execute this machine code because C and C++ compiler, creates machine code based on processor particular processor is having.
To solve this problem, James gosling came up with a solution. Instead of creating machine code which can be understood by every processor, we create a standard machine on top of every type of processor. The machine created knows how to communicate with every type of processor. On compilation, we create machine code which is understood by this machine. This machine is called virtual machine.
JVM is build using C and C++, because C and C++ language has the capability to communicate with the processor quickly. That is why they are faster than java.
In some word it provides the runtime environment to the use the java code and its applications. Here the main process involves,firstly it convert source code or program given by the developer into byte code and execute the program according to the byte code. Its can be shown as Source code --> Byte code --> Execution Takes Practical Definition of โ(Java Virtual Machine) acts as a run-time engine to run Java applications, It understands machine code, A Java virtual machine is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. JVM is the one, which provides the java facility to compile one and run it anywhere.โ
Compilation and Execution process of JVM:-
1)Write The Program:- Any program written in Java or other language is written by the programmer. Ex:- Hello world program public class Main { public static void main(String[] args) { System.out.println("Hello world!"); } }
2)Run and Execute :- After completion of program the program is set to run by the developer. Here the program code is converted into machine code Ex:- Execute and run the hello world program.
3) Byte code:- it is provided internally .
4) Execution :- Execute the code from the OS and provide the final result.
I m Mayank Sharma
Persuing Btech II year from Gwalior M.p
Do you want to connect with me:๐
linkedin : %[linkedin.com/in/mayank-sharma-866147232?lip..
Instagram: %[instagram.com/_mayank__dwivedi