Home » Java programming language

How to get the Java VM specifications in Java?

Java VM specifications example: Here, we are going to learn how to get and print the Java VM specifications in Java?
Submitted by IncludeHelp, on September 18, 2019

To get the details of the Java VM specifications, we use the getProperties() method, which is defined in System class, while calling the method, we need to pass the property names to get the Java VM specifications.

There are following Java VM specifications that we can get using the following properties,

  • java.vm.specification.version – it is used to get the Java VM specification version.
  • java.vm.specification.vendor – it is used to get the Java VM specification vendor name.
  • java.vm.specification.name – it is used to get the Java VM specification name.

Java code to get and print the Java VM specifications

// Java program to demonstrate the example of 
// getProperties() method of System Class

import java.lang.*;
import java.util.Properties;

public class Main {
    public static void main(String[] args) {
        String vm_spec_ver = null;
        String vm_spec_ven = null;
        String vm_spec_nam = null;
        
        vm_spec_ver = System.getProperty("java.vm.specification.version");
        vm_spec_ven = System.getProperty("java.vm.specification.vendor");
        vm_spec_nam = System.getProperty("java.vm.specification.name");
        
        System.out.println("Java Virtual Machine Specification Version: " + vm_spec_ver);
        System.out.println("Java Virtual Machine Specification Vendor : " + vm_spec_ven);
        System.out.println("Java Virtual Machine Specification Name   : " + vm_spec_nam);
    }
}

Output

Java Virtual Machine Specification Version: 10
Java Virtual Machine Specification Vendor : Oracle Corporation
Java Virtual Machine Specification Name   : Java Virtual Machine Specification


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.