Program to find java version

We can easily find the version of java during program execution. There are few System property available which are provide this information.

public class Version
{
    public static void main(String args[])
    {
        // Find version.
        System.out.println(System.getProperty("java.version"));
    }
}
1.8.0_201

When you need more information you can get this way.

public class VersionInfo
{
    public static void main(String args[])
    {
        // Get more information
        System.out.println(System.getProperty("java.vendor"));
        System.out.println(System.getProperty("java.vendor.url"));
        System.out.println(System.getProperty("java.vendor.url.bug"));
        System.out.println(System.getProperty("java.specification.name"));
        System.out.println(System.getProperty("java.specification.vendor"));
        System.out.println(System.getProperty("java.specification.version"));
        System.out.println(System.getProperty("java.vm.name"));
        System.out.println(System.getProperty("java.vm.vendor"));
        System.out.println(System.getProperty("java.vm.version"));
        System.out.println(System.getProperty("java.vm.info"));
        System.out.println(System.getProperty("java.vm.specification.name"));
        System.out.println(System.getProperty("java.vm.specification.vendor"));
        System.out.println(System.getProperty("java.vm.specification.version"));
        System.out.println(System.getProperty("java.vm.version"));
        System.out.println(java.lang.management.ManagementFactory.getRuntimeMXBean().getVmVersion());
        System.out.println(System.getProperty("java.runtime.name"));
        System.out.println(System.getProperty("java.runtime.version"));
        System.out.println(System.getProperty("java.class.version"));
        System.out.println(System.getProperty("jdk.debug"));
        System.out.println(System.getProperty("sun.java.launcher"));
        System.out.println(System.getProperty("sun.management.compiler"));
        System.out.println(System.getProperty("java.vendor.version"));
        System.out.println(System.getProperty("java.version.date"));
    }
}

Output

Oracle Corporation
http://java.oracle.com/
http://bugreport.sun.com/bugreport/
Java Platform API Specification
Oracle Corporation
1.8
Java HotSpot(TM) 64-Bit Server VM
Oracle Corporation
25.201-b09
mixed mode
Java Virtual Machine Specification
Oracle Corporation
1.8
25.201-b09
25.201-b09
Java(TM) SE Runtime Environment
1.8.0_201-b09
52.0
null
SUN_STANDARD
HotSpot 64-Bit Tiered Compilers
null
null

Note result can be different because its based on java version.




Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2022, kalkicode.com, All rights reserved