JVM stands for Java Virtual Machine. It is an abstract computing machine that allows the computer to run Java programs. It is a platform-independent environment that is responsible for compiling Java programs by converting Java code into machine language, that is, bytecode. The memory required by the JVM to run Java programs is called heap memory.
In Java, the getProperty() method is used to obtain information about various system-related properties. Similarly, there are two different ways to use the system property " sun.arch.data.model" or "os. arch. "It will return 32-bit or 64-bit, depending on your Java installation.
The method required: get.Property()
Syntax:
String System.getProperty( String key )
Parameter:
Key is the property of the operating system
Return Type
1) Returns a string containing the value of the property
2) Returns Null if the property does not exist
There are basically 3 methods to check whether the JVM is 32 bit or 64 bit:-
Using sun.arch.data.model
// Java Program to check bitness of JVM by // using System property "sun.arch.data.model" public class checkBit { // get bitness of JVM private static final String a = System.getProperty("sun.arch.data.model"); public static void main(String[] args) { // printing the JVM version System.out.println("JVM is " + a + " bit"); } }
Using os.arch.model
// Java Program to check bitness of JVM by // using System property "os.arch.model" public class bit { // get bitness of JVM private static final String s = System.getProperty("os.arch"); public static void main(String[] args) { // printing the of what bit JVM is System.out.println("JVM is " + s + " bit"); } }