• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » Java » Evolution » Java Virtual Machine (JVM) & its Architecture
Next →
← Prev

Java Virtual Machine (JVM) & its Architecture

By Dinesh Thakur

What is JVM (Java Virtual Machine): Most programming languages such as C/C++ compile source code directly into machine code suitable for execution on a particular microprocessor architecture or operating systems such as Windows or Unix. This property does not make these languages’ architecturally neutral’. However, Java is an architectural neutral language as it follows. Write once execute anywhere approach. This feature of Java achieved as the Java compiler does not translate the source code into the machine language of the computer that the program is running on. Instead, the compiler translates source code into bytecode which is not understood by the underlying operating system. So an application is needed that can convert this bytecode into machine code understood by the underlying operating system. It is accomplished using the Java Virtual Machine.

You can think of the Java Virtual Machine (JVM) as an open computer platform – a design for a computer that does not exist as actual hardware. Instead, it is an emulator, i.e., a program that sets aside a part of your hard drive to act like a computer (namely the JVM) that can execute Java programs. Because of JVM, you can execute a Java program on any computer that has a Java runtime environment installed without recompiling the program. It is how Java provides platform independence. It is the Virtual Machine that does all the code processing, and because Oracle owns Java, you must have the Virtual Machine or Java Runtime Environment.

Java is both compiled and an interpreted language. When you start writing your Java code, you do it in a text editor, and NetBeans is all set up to provide you with the place to write it all. The code is known as source code and is always saved with a file extension of .java. A program called Javac will then turn that source code into Java Byte Code in a process that is known as compiling. First, the java compiler translates source code into the byte code instructions. Once the code has been compiled by Javac, it gets saved again, this tie with a file extension of .class. In the next stage, the java interpreter converts the byte code instructions to machine code. However, this can only be done if the code is free of errors. When the class file is ready, that can be directly executed by the machine running the JVM (Java Virtual Machine). The intermediate code namely the bytecode produced by the java compiler is for a machine that exists only on the memory of a computer. So:

JAVA VIRTUAL MACHINE● Your source code is created and saved with the .java extension.
● Javac then compiles the code and saves it with the .class extension.
● Your compiled class can be run on the JVM  NetBeans is designed to make your life very easy. It does all the creating and compiling for you; behind the scenes, it is working the magic of transforming source code to java files, using Javac to compile and then running your new .class file in its built-in software. It saves you having to open terminal windows and type in long, complicated strings of text, as you do with other programming languages.  Okay, so that is how NetBeans works with Java, time to open NetBeans – we are going to write a program. Writing code is the best way of learning how it all works so go ahead and do what you need to – if you haven’t installed NetBeans yet go and do it. Then open it and get ready to follow along with the rest of this section.

This machine or the ‘Simulated computer within the computer’ is known as the “Java Virtual Machine” or JVM.

The JVM can be thought as a mini operating system that forms a layer of abstraction where the underlying hardware. The operating system and the compiled code is concerned the compiler converts the source code into a code that is based on the imaginary computer instructions set. The compiled code is not processor specific.

The interpreter converts these instructions for the underlying hardware to which the interpreter is targeted. The portability feature of the .class file helps in the execution of the prg on any computer with the java virtual machine. This helps in implementing the “write once and run any where” feature of java.

We’ll be covering the following topics in this tutorial:

  • Lifetime of a JVM
  • JVM Architecture

Lifetime of a JVM

The runtime instance of the java virtual machine has a clear mission in life. To run one java application. When a java application starts a run time instance is ban when the application completes the instance dies. If you start three java applications at the same time on the same computer using the same can create and implementation.

You will get three JVM instances. Each java application runs inside its own java virtual machine. A java virtual machine instance starts running its solitary application by invoking the main() method of some initial class. The main() method must be public, static, return void and accept one parameter: a string array. Any class with such a main() method can be used as the starting point for a java application.

JVM Architecture

 

ClassLoader: It is the sub-system of JVM. When the compiler successfully compiles the java source code, then it generates java byte codes Java bytecodes are residing in the .class file. Internally .class file resides in the current working directory. Class loader subsystem takes the copy of the class file and loads it in the memory before JVM executes java bytecodes.

It Loads the .class file into memory and checks the correctness of the .class file. It allocates the memory to the static block and static variable. If the static variable is not initialized it assigned the default value to the static variable and the static the variable initialized when the class file loaded in the memory.

Method Area: It is just a logical memory component of JVM. It holds information about the class’ and interface. All the static variable, static block, static method resides in the method area. Size of method area not fixed because it’s size depends on the size of the application.

Heap Area: Heap is another logical memory component used by JVM. When the program constructs the object through the memory from the heap.

Java Stacks: It is another logical component used by JVM. Java language Stacks are used by the virtual machine to store local variables, and it’s partial results. Each thread creates its own JVM stack. This area has create one stack frame for each thread. Once the thread execution completed, this stack frame also gets deleted.

PC Registers: It is popularly known as the program counter register. PC register holds the address of the JVM instruction which is currently executing. In Java, each thread has its PC register to hold the address of the currently executing instruction.

Native method Area: Native method stacks hold the instruction of native method information on the native library — it writes in a different language instead of Java. In java, Every thread has a separate native method stack.

Execution Engine: It treated as a virtual processor, and it generates, manages & executes java bytecodes. It is a type of software used to test hardware, software, or complete systems. The test execution engine never carries any information about the tested product.

Native Method interface: The Native Method Interface is a programming framework. It allows Java code which is running in a JVM to call by libraries and native applications.

Native Method Libraries: It is a collection of the Native Libraries(C, C++) which are needed by for the Execution Engine.

You’ll also like:

  1. What is Machine Code or Machine Language?
  2. Difference Between JRE ,JDK and JVM
  3. Virtual and virtual path Circuit
  4. What is Automated Teller Machine (ATM)?
  5. Difference between Virtual Circuit (VC) and Permanent Virtual Circuit (PVC)
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

Java Tutorials

Java Tutorials

  • Java - Home
  • Java - IDE
  • Java - Features
  • Java - History
  • Java - this Keyword
  • Java - Tokens
  • Java - Jump Statements
  • Java - Control Statements
  • Java - Literals
  • Java - Data Types
  • Java - Type Casting
  • Java - Constant
  • Java - Differences
  • Java - Keyword
  • Java - Static Keyword
  • Java - Variable Scope
  • Java - Identifiers
  • Java - Nested For Loop
  • Java - Vector
  • Java - Type Conversion Vs Casting
  • Java - Access Protection
  • Java - Implicit Type Conversion
  • Java - Type Casting
  • Java - Call by Value Vs Reference
  • Java - Collections
  • Java - Garbage Collection
  • Java - Scanner Class
  • Java - this Keyword
  • Java - Final Keyword
  • Java - Access Modifiers
  • Java - Design Patterns in Java

OOPS Concepts

  • Java - OOPS Concepts
  • Java - Characteristics of OOP
  • Java - OOPS Benefits
  • Java - Procedural Vs OOP's
  • Java - Polymorphism
  • Java - Encapsulation
  • Java - Multithreading
  • Java - Serialization

Java Operator & Types

  • Java - Operator
  • Java - Logical Operators
  • Java - Conditional Operator
  • Java - Assignment Operator
  • Java - Shift Operators
  • Java - Bitwise Complement Operator

Java Constructor & Types

  • Java - Constructor
  • Java - Copy Constructor
  • Java - String Constructors
  • Java - Parameterized Constructor

Java Array

  • Java - Array
  • Java - Accessing Array Elements
  • Java - ArrayList
  • Java - Passing Arrays to Methods
  • Java - Wrapper Class
  • Java - Singleton Class
  • Java - Access Specifiers
  • Java - Substring

Java Inheritance & Interfaces

  • Java - Inheritance
  • Java - Multilevel Inheritance
  • Java - Single Inheritance
  • Java - Abstract Class
  • Java - Abstraction
  • Java - Interfaces
  • Java - Extending Interfaces
  • Java - Method Overriding
  • Java - Method Overloading
  • Java - Super Keyword
  • Java - Multiple Inheritance

Exception Handling Tutorials

  • Java - Exception Handling
  • Java - Exception-Handling Advantages
  • Java - Final, Finally and Finalize

Data Structures

  • Java - Data Structures
  • Java - Bubble Sort

Advance Java

  • Java - Applet Life Cycle
  • Java - Applet Explaination
  • Java - Thread Model
  • Java - RMI Architecture
  • Java - Applet
  • Java - Swing Features
  • Java - Choice and list Control
  • Java - JFrame with Multiple JPanels
  • Java - Java Adapter Classes
  • Java - AWT Vs Swing
  • Java - Checkbox
  • Java - Byte Stream Classes
  • Java - Character Stream Classes
  • Java - Change Color of Applet
  • Java - Passing Parameters
  • Java - Html Applet Tag
  • Java - JComboBox
  • Java - CardLayout
  • Java - Keyboard Events
  • Java - Applet Run From CLI
  • Java - Applet Update Method
  • Java - Applet Display Methods
  • Java - Event Handling
  • Java - Scrollbar
  • Java - JFrame ContentPane Layout
  • Java - Class Rectangle
  • Java - Event Handling Model

Java programs

  • Java - Armstrong Number
  • Java - Program Structure
  • Java - Java Programs Types
  • Java - Font Class
  • Java - repaint()
  • Java - Thread Priority
  • Java - 1D Array
  • Java - 3x3 Matrix
  • Java - drawline()
  • Java - Prime Number Program
  • Java - Copy Data
  • Java - Calculate Area of Rectangle
  • Java - Strong Number Program
  • Java - Swap Elements of an Array
  • Java - Parameterized Constructor
  • Java - ActionListener
  • Java - Print Number
  • Java - Find Average Program
  • Java - Simple and Compound Interest
  • Java - Area of Rectangle
  • Java - Default Constructor Program
  • Java - Single Inheritance Program
  • Java - Array of Objects
  • Java - Passing 2D Array
  • Java - Compute the Bill
  • Java - BufferedReader Example
  • Java - Sum of First N Number
  • Java - Check Number
  • Java - Sum of Two 3x3 Matrices
  • Java - Calculate Circumference
  • Java - Perfect Number Program
  • Java - Factorial Program
  • Java - Reverse a String

Other Links

  • Java - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW