Tuesday, 17 May 2016

How to check Host JVM is 32 or 64 bit in Java?

1) By using System property "sun.arch.data.model"

public class JavaVersion {

   public static void main(String[] args) {
      String jvm_version = System.getProperty("sun.arch.data.model");
      System.out.println("JVM Bit size: " + jvm_version);
     
   }
}

Output:
JVM Bit size: 32

2) By using System Property "os.arch"

public class JavaVersion {

   public static void main(String[] args) {
      String jvm_version = System.getProperty("sun.arch.data.model");
     
      System.out.println("JVM Bit size: " + System.getProperty("os.arch"));
   }
}
Output:
JVM Bit size: x86

3) java -d64 -version
We can get the java version by running this command on command prompt. It works fine on Windows 7 but not for Windows XP.

4) java –version
Running this command on command prompt returns the complete information along with java version.


No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...