Determining whether your application is running on a 32-bit (31-bit on IBM Z) or 64-bit JVM

Some Java™ applications must be able to determine whether they are running on a 32-bit (31-bit on IBM Z®) or 64-bit JVM.

About this task

If your application has a native code library, the library must be compiled separately in 32-bit (31-bit on IBM Z) and 64-bit forms for platforms that support both 32-bit and 64-bit modes of operation. In this case, your application must load the correct library at run time, because it is not possible to mix 32-bit (31-bit on IBM Z) and 64-bit code.

For Eclipse OpenJ9 VM, the system property com.ibm.vm.bitmode allows applications to determine the mode in which your JVM is running. It returns the following values:
  • 32 - the JVM is running in 32-bit (31-bit on IBM Z) mode
  • 64 - the JVM is running in 64-bit mode
You can inspect the com.ibm.vm.bitmode property from inside your application code using the call: System.getProperty("com.ibm.vm.bitmode");