Goseeko blog

What is Java Virtual Machine?

by Bhumika

The Java Virtual Machine (JVM) is a machine that is abstract. It’s a runtime environment for executing Java bytecode. For a variety of hardware and software platforms, JVMs are available.

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.

The role of JVM in Java

JVM is require in both JDK and JRE and is responsible for transforming byte-code to machine-specific code. It’s also platform-dependent and handles a variety of tasks, such as memory management and security. JVM may also run programmes that have been translate to Java byte-code from other programming languages.

The Java Native Interface (JNI) is a term that is frequently use in conjunction with the Java Virtual Machine (JVM). JNI is a programming framework that allows Java code running in the JVM to interact with (i.e., call and be called by) programmes associated with certain hardware and operating systems. Native applications are those that are written in a language other than English. In addition, To bring native code written in other languages into a Java programme, native methods are use.

JVM components

JVM is consists of three key parts or subsystems:

  • The Class Loader Subsystem is in charge of dynamic class loading, which entails loading, linking, and initialising a Java class file (i.e., “Java file”).
  • Method area, PC registers, stack areas, and threads are all part of the Runtime Data Areas.
  • An interpreter, compiler, and garbage collection area are all part of the Execution Engine.

JVM Memory 

  • Method area: All class-level information, including static variables, is saved in the method area, including the class name, immediate parent class name, methods and variables information, and so on. Each JVM has only one method area, which is a shared resource.
  • Heap area: The heap region is where all object information is kept. Each JVM has its own Heap Area. It’s also a resource that’s share.
  • Stack area: JVM builds one run-time stack for each thread, which save here. Every block in this stack is referred to as an activation record/stack frame, and it is used to store method calls. All of that method’s local variables are save in the frame that corresponds to them. JVM will trash a thread’s run-time stack after it has terminated. It isn’t a resource that can shared.
  • PC Registers: Save the address of a thread’s current execution instruction. Each thread, obviously, has its own PC Registers.
  • Native method stacks: A distinct native stack is construct for each thread. It keeps track of native methods.

Interested in learning about similar topics? Here are a few hand-picked blogs for you!

You may also like