Java Virtual Machine (JVM) is a runtime environment that allows Java code or applications to run. It translates Java bytecode into machine code. The Java Virtual Machine (JVM) is a component of the Java Runtime Environment (JRE). The compiler in other programming languages generates machine code for a specific system. The Java compiler, on the other hand, generates code for the Java Virtual Machine.
JVM Workflow process
Java code is first compiled into bytecode. On different machines, this bytecode is interpreted.
Bytecode serves as a bridge between the host system and the Java source code. The Java Virtual Machine (JVM) is in charge of memory allocation.
JVM Architecture
Let’s look at the architecture of JVM in this JVM tutorial. Java’s JVM architecture includes a classloader, memory space, and execution engine, among other things.
1) ClassLoader
The class loader is a subsystem that handles class file loading. Loading, linking, and initialization are the three key functions it performs.
2) Method Area
Class structures such as metadata, the constant runtime pool, and method code are all stored in the JVM Method Area.
3) Heap
The heap stores all Objects, their associated instance variables, and arrays. This is a shared memory that spans numerous threads.
4) JVM language Stacks
Local variables and partial results are stored in Java language stacks. Each thread has its own JVM stack, which is created at the same time as the thread. When a method is called, a new frame is formed, and it is removed once the method has been called.
5) PC Registers
The address of the currently executing Java virtual machine instruction is stored in the PC register. Each thread in Java has its own PC register.
6) Native Method Stacks
The instructions of native code are stored in native method stacks, which are dependent on the native library. Instead of Java, it is written in a different language.
7) Execution Engine
It’s a form of programme that’s used to evaluate hardware, software, and entire systems. The test execution engine never stores any data about the product being tested.
8) Native Method interface
The Native Method Interface is a framework for programming. It allows libraries and native programmes to call Java code executing in a JVM.
9) Native Method Libraries
Native Libraries is a group of Native Libraries (C, C++) that the Execution Engine requires.
Software Code Compilation & Execution process
You’ll need the following to write and run a software programme:
1) Editor – A notepad could be used to write your software onto.
2) Compiler – To translate your high-level programming language into native machine code.
3) Linker – To link together multiple programme files that are referenced in your main application
4) Loader – To execute files from a secondary storage device such as a hard disc, flash drive, or CD, you must first load them into RAM. When you run your code, the loading is done automatically.
5) Execution – The actual code execution, which is handled by your operating system and processor.