search
HomeJavajavaTutorialDetailed overview of Java virtual machine

Detailed overview of Java virtual machine

Jun 20, 2017 pm 02:35 PM
javaOverviewstructurevirtual

1. Overview of Java virtual machine

The Java technology system officially defined by Oracle mainly includes the following parts:

  • Java Programming Language

  • Java virtual machine for various platforms

  • Class file format

  • Java API class Library

  • Third-party Java class library

The three parts of Java programming language, Java virtual machine and Java API class library can be collectively referred to as JDK (Java Development Kit), which is the minimum environment for Java program development. In addition, the Java SE API subset and Java virtual machine in the Java API are collectively called JRE (Java Runtime Environment), which is the standard environment for Java programs to run.

The reason why the Java virtual machine is called "virtual" is because it is just an abstract computer defined by a specification.

2. Java Virtual Machine Family

Many students may think that the Java virtual machine is just a virtual machine. Does it have a family? Or think that the Java virtual machine refers to Oracle's HotSpot virtual machine. Here is a brief introduction to the Java virtual machine family. Since the Sun Classic VM included in JDK1.0 released by Sun in 1996 to today, many types of virtual machines have appeared and disappeared. Here we will only briefly introduce the relatively mainstream Java virtual machines that currently exist. .

HotSpot VM
The virtual machines that come with Oracle JDK and OpenJDK are the most mainstream and widely used Java virtual machines. Technical articles introducing the Java virtual machine, unless otherwise specified, most of them introduce HotSpot VM. HotSpot VM was not developed by Sun, but was designed by Longview Technologies, a small company. It was acquired by Sun in 1997, and Sun was acquired by Oracle in 2009.
J9 VM
J9 VM is a VM developed by IBM and is currently its main development Java virtual machine. The market positioning of J9 VM is close to that of HotSpot VM. It is a multi-purpose virtual machine designed with everything from server to desktop application to embedded in mind. The current performance level of J9 VM is roughly on the same level as HotSpot VM.
Zing VM
Based on Oracle's HotSpot VM, many details that affect latency have been improved. The three biggest selling points are:

  • 1. Low latency, "no pause" C4 GC, the pause caused by GC can be controlled below 10ms, and the supported Java heap size Can reach 1TB;

  • #2. Quick warm-up function after startup.

  • 3. Manageability: Zing Vision, a monitoring tool integrated into the JVM that has zero overhead and can be turned on at all times in the production environment.

3. Java virtual machine execution process

When we execute a Java program, what is its execution process? As shown below.

As you can see from the above figure, the Java virtual machine has no necessary connection with the Java language. It is only related to a specific binary file: the Class file..

4.Java virtual machine structure

The architecture mentioned here refers to the abstract behavior of the Java virtual machine, rather than the specific implementation of HotSpot VM. . According to the Java virtual machine specification, the abstract Java virtual machine is shown in the figure below.

##JVM = classloader classloader + execution engine execution engine + runtime data area runtime data area

. classloader loads the class file on the hard disk into the runtime data area in the JVM, but it is not responsible for whether the class file can be executed, and this is the responsibility of the execution engine .

The Java virtual machine abstract specification is just a concept. Generally speaking, the Java virtual machine is a specific implementation of the specification. This implementation may come from multiple providers and exist on multiple platforms. It can be implemented entirely in software, or in a combination of hardware and software.

5. The life cycle of the virtual machine

The bounden duty of a runtime Java virtual machine instance is: responsible for running a java program.

When a Java program is started, a virtual machine instance is born. When the program is closed and exited, the virtual machine instance will also die

. If three Java programs are run simultaneously on the same computer, three Java virtual machine instances will be obtained. Each Java program runs in its own Java virtual machine instance. A Java virtual machine instance runs a Java program by calling the main() method of an initial class. The main() method must be public, static, return void, and accept a string array as a parameter. Any class with such a main() method can be used as the starting point for running a Java program.

public class Test {public static void main(String[] args) {// TODO Auto-generated method stubSystem.out.println("Hello World");
    }

}

In the above example, the main() method in the initial class of the Java program will be used as the starting point of the initial thread of the program, and any other threads are started by this initial thread.

There are two kinds of threads inside the Java virtual machine: daemon threads and non-daemon threads. Daemon threads are usually used by the virtual machine itself, such as threads that perform garbage collection tasks. However, a Java program can also mark any thread it creates as a daemon thread. The initial thread in the Java program - the one that starts in main(), is a non-daemon thread.

As long as there are any non-daemon threads running, the Java program will continue to run. When all non-daemon threads in the program terminate, the virtual machine instance will automatically exit . If the security manager allows it, the program itself can also exit by calling the exit() method of the Runtime class or the System class.

The above is the detailed content of Detailed overview of Java virtual machine. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Is Java Platform Independent if then how?Is Java Platform Independent if then how?May 09, 2025 am 12:11 AM

Java is platform-independent because of its "write once, run everywhere" design philosophy, which relies on Java virtual machines (JVMs) and bytecode. 1) Java code is compiled into bytecode, interpreted by the JVM or compiled on the fly locally. 2) Pay attention to library dependencies, performance differences and environment configuration. 3) Using standard libraries, cross-platform testing and version management is the best practice to ensure platform independence.

The Truth About Java's Platform Independence: Is It Really That Simple?The Truth About Java's Platform Independence: Is It Really That Simple?May 09, 2025 am 12:10 AM

Java'splatformindependenceisnotsimple;itinvolvescomplexities.1)JVMcompatibilitymustbeensuredacrossplatforms.2)Nativelibrariesandsystemcallsneedcarefulhandling.3)Dependenciesandlibrariesrequirecross-platformcompatibility.4)Performanceoptimizationacros

Java Platform Independence: Advantages for web applicationsJava Platform Independence: Advantages for web applicationsMay 09, 2025 am 12:08 AM

Java'splatformindependencebenefitswebapplicationsbyallowingcodetorunonanysystemwithaJVM,simplifyingdeploymentandscaling.Itenables:1)easydeploymentacrossdifferentservers,2)seamlessscalingacrosscloudplatforms,and3)consistentdevelopmenttodeploymentproce

JVM Explained: A Comprehensive Guide to the Java Virtual MachineJVM Explained: A Comprehensive Guide to the Java Virtual MachineMay 09, 2025 am 12:04 AM

TheJVMistheruntimeenvironmentforexecutingJavabytecode,crucialforJava's"writeonce,runanywhere"capability.Itmanagesmemory,executesthreads,andensuressecurity,makingitessentialforJavadeveloperstounderstandforefficientandrobustapplicationdevelop

Key Features of Java: Why It Remains a Top Programming LanguageKey Features of Java: Why It Remains a Top Programming LanguageMay 09, 2025 am 12:04 AM

Javaremainsatopchoicefordevelopersduetoitsplatformindependence,object-orienteddesign,strongtyping,automaticmemorymanagement,andcomprehensivestandardlibrary.ThesefeaturesmakeJavaversatileandpowerful,suitableforawiderangeofapplications,despitesomechall

Java Platform Independence: What does it mean for developers?Java Platform Independence: What does it mean for developers?May 08, 2025 am 12:27 AM

Java'splatformindependencemeansdeveloperscanwritecodeonceandrunitonanydevicewithoutrecompiling.ThisisachievedthroughtheJavaVirtualMachine(JVM),whichtranslatesbytecodeintomachine-specificinstructions,allowinguniversalcompatibilityacrossplatforms.Howev

How to set up JVM for first usage?How to set up JVM for first usage?May 08, 2025 am 12:21 AM

To set up the JVM, you need to follow the following steps: 1) Download and install the JDK, 2) Set environment variables, 3) Verify the installation, 4) Set the IDE, 5) Test the runner program. Setting up a JVM is not just about making it work, it also involves optimizing memory allocation, garbage collection, performance tuning, and error handling to ensure optimal operation.

How can I check Java platform independence for my product?How can I check Java platform independence for my product?May 08, 2025 am 12:12 AM

ToensureJavaplatformindependence,followthesesteps:1)CompileandrunyourapplicationonmultipleplatformsusingdifferentOSandJVMversions.2)UtilizeCI/CDpipelineslikeJenkinsorGitHubActionsforautomatedcross-platformtesting.3)Usecross-platformtestingframeworkss

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use