Home >Java >javaTutorial >What are the different versions of the Java Virtual Machine?
The Java Virtual Machine (JVM) is responsible for running Java bytecode and has multiple versions. Major releases include Java 8 (introducing Lambda expressions, streams API), Java 11 (improved garbage collector), Java 14 (introducing pattern matching), and Java 17 (introducing sealed classes). In order to check the JVM version, you can use System.getProperties() to get the Java version.
Different versions of Java Virtual Machine
Overview
Java Virtual Machine( JVM) is responsible for running Java bytecode, which is a key component of Java program execution. It comes in multiple versions, each offering different features and improvements.
Main Version
Version | Release Date | Main Features |
---|---|---|
2014 | Lambda expression, stream API, time and date API | |
2018 | Local variable symbol table, garbage collector improvements, module system enhancements | |
2020 | Pattern matching, logging, JShell improvements | |
2021 | Sealed classes, text conversion API, Switch expression |
Practical case: Java version check
In order to check the JVM version running the Java program, you can use The following code:import java.util.Properties; public class JavaVersionCheck { public static void main(String[] args) { // 获取系统属性 Properties props = System.getProperties(); // 获取 Java 版本 String javaVersion = props.getProperty("java.version"); // 打印 Java 版本 System.out.println("Java 版本:" + javaVersion); } }
Output:
Java 版本:11.0.13This will print the JVM version of the running program.
The above is the detailed content of What are the different versions of the Java Virtual Machine?. For more information, please follow other related articles on the PHP Chinese website!