How can I tell if I'm running in 64-bit JVM or 32-bit JVM (from within a program)?

0 votes
asked Jan 14, 2010 by bobmcgee

How can I tell if the JVM my application runs in is 32 bit or 64-bit? Specifically, what function or preference do I access to detect this within the program?

9 Answers

0 votes
answered Jan 14, 2010 by codaddict

Sun has a Java System property to determine the bitness of the JVM: 32 or 64: // 32 bit JVM // 64 bit JVM

You can use


to determine if its 32/64 from the program.

From the Sun HotSpot FAQ:

When writing Java code, how do I distinguish between 32 and 64-bit operation?

There's no public API that allows you to distinguish between 32 and 64-bit operation. Think of 64-bit as just another platform in the write once, run anywhere tradition. However, if you'd like to write code which is platform specific (shame on you), the system property has the value "32", "64", or "unknown".

The only good reason is if your java code is dependent upon native libraries and your code needs to determine which version (32 or 64bit) to load on startup.

0 votes
answered Jan 14, 2010 by bryantsai

Update Again:

I installed 32-bit JVM and retried it again, looks like the following does tell you JVM bitness, not OS arch:

# on a 64-bit Linux box:
# "x86" when using 32-bit JVM
# "xmd64" when using 64-bit JVM

This was tested against both SUN and IBM JVM (32 and 64-bit). Clearly, the system property is not just the operating system arch.

0 votes
answered Jan 14, 2010 by gpampara

You can try on the command line:

java -d64 -version

If it's not a 64-bit version, you'll get a message that looks like:

This Java instance does not support a 64-bit JVM. Please install the desired version.

Consult the help options of the JVM for more info java -help

0 votes
answered Jan 3, 2011 by sedat-kilinc

Just type java -version in your console.

If a 64 bit version is running, you'll get a message like:

java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) 64-Bit Server VM (build 16.0-b13, mixed mode)

A 32 bit version will show something similar to:

java version "1.6.0_41"
Java(TM) SE Runtime Environment (build 1.6.0_41-b02)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode, sharing)

Note Client instead of 64-Bit Server in the third line. The Client/Server part is irrelevant, it's the absence of the 64-Bit that matters.

If multiple Java versions are installed on your system, navigate to the /bin folder of the Java version you want to check, and type java -version there.

0 votes
answered Jan 7, 2012 by jawsnnn

On Linux, you can get ELF header information by using either of the following two commands:

file {YOUR_JRE_LOCATION_HERE}/bin/java

o/p: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), for GNU/Linux 2.4.0, not stripped


readelf -h {YOUR_JRE_LOCATION_HERE}/bin/java | grep 'Class'

o/p: Class: ELF64

0 votes
answered Jan 16, 2012 by dim

Complementary info:

On a running process you may use (at least with some recent Sun JDK5/6 versions):

$ /opt/java1.5/bin/jinfo -sysprops 14680 | grep
Attaching to process ID 14680, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 1.5.0_16-b02 = 32

where 14680 is PID of jvm running the application. "os.arch" works too.

Also other scenarios are supported:

jinfo [ option ] pid
jinfo [ option ] executable core
jinfo [ option ] [server-id@]remote-hostname-or-IP 

However consider also this note:

"NOTE - This utility is unsupported and may or may not be available in future versions of the JDK. In Windows Systems where dbgent.dll is not present, 'Debugging Tools for Windows' needs to be installed to have these tools working. Also the PATH environment variable should contain the location of jvm.dll used by the target process or the location from which the Crash Dump file was produced."

0 votes
answered Jan 6, 2015 by user1364368

Under Windows 7 in the "Control Panel" under "Programs | Programs and Features" the 64-bit variants of JRE & JDK are listed with "64-bit" in parentheses (e.g. "Java SE Development Kit 7 Update 65 (64-Bit)"), while for the 32-bit variants the variant is not mentioned in parentheses (e.g. just "Java SE Development Kit 8 Update 60").

0 votes
answered Jan 10, 2015 by anthony-hayward

If you are using JNA, you can check whether com.sun.jna.Native.POINTER_SIZE == 4 (32 bit) or com.sun.jna.Native.POINTER_SIZE == 8 (64 bit).

0 votes
answered Sep 15, 2017 by olu

If its not too late, you can also try using JMX like this..


 OperatingSystemMXBean os = (OperatingSystemMXBean) ManagementFactory
Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter