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).

JVM is the one that makes java platform independent.

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.

JVM Architecture

method area.

Method Area: There is only one method area in a JVM which is shared among all the classes. This holds the class level information of each .class file.

Heap: Heap is a part of JVM memory where objects are allocated. JVM creates a Class object for each .class file.

Stack: Stack is a also a part of JVM memory but unlike Heap, it is used for storing temporary variables.

PC Registers: This keeps the track of which instruction has been executed and which one is going to be executed. Since instructions are executed by threads, each thread has a separate PC register.

Native Method stack: A native method can access the runtime data areas of the virtual machine.

Native Method interface: It enables java code to call or be called by native applications. Native applications are programs that are specific to the hardware and OS of a system.

Garbage collection: A class instance is explicitly created by the java code and after use it is automatically destroyed by garbage collection for memory management.

JVM Vs JRE Vs JDK

Which means you can run the code in JRE but you can’t develop and compile the code in JRE.

 

https://beginnersbook.com/2013/05/jvm/

相关文章:

  • 2021-09-27
  • 2021-11-11
  • 2021-10-07
  • 2021-10-04
  • 2021-12-23
  • 2022-01-06
  • 2021-08-14
  • 2021-11-29
猜你喜欢
  • 2021-11-07
  • 2021-05-13
  • 2021-10-04
  • 2021-07-18
  • 2021-12-02
  • 2021-11-28
  • 2021-08-18
相关资源
相似解决方案