dynamic - determine os architecture and bitness in java -
i want able dynamically determine os, architecture, , bit-ness in java application.
for example, application know when on solaris 32-bit sparc machine or when on x86 machine.
i know system property returns arch of jvm, there find out real os arch , bit-ness?
the simplest way byte order use byteorder.nativeorder();
the os in system properties.
to determine if jvm 64-bit use following taken ehcache.
private static final boolean is64bit = is64bit0(); public static boolean is64bit() { return is64bit; } private static boolean is64bit0() { string systemprop; systemprop = system.getproperty("com.ibm.vm.bitmode"); if (systemprop != null) { return systemprop.equals("64"); } systemprop = system.getproperty("sun.arch.data.model"); if (systemprop != null) { return systemprop.equals("64"); } systemprop = system.getproperty("java.vm.version"); return systemprop != null && systemprop.contains("_64"); }
Comments
Post a Comment