Jump to Real's How-to Main page

Detect if running in a 64bit JVM

public static boolean is64BitVM() {
  String bits = System.getProperty("sun.arch.data.model", "?");
  if (bits.equals("64") {
     return true;
  }
  if (bits.equals("?") {
     // probably sun.arch.data.model isn't available
     // maybe not a Sun JVM?
     // try with the vm.name property
     return 
        System.getProperty("java.vm.name")
           .toLowerCase().indexOf("64") >= 0;
    } 
  // probably 32bit
  return false;
  }
}

If you find this article useful, consider making a small donation
to show your support for this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2007
[ home ]