unix

How do I tell if my Java JVM is 32-bit or 64-bit on my Linux server or desktop?

There are a few different ways to determine if your Java JVM is 32-bit or 64-bit.

1. Use the file command.

Ex. file /usr/bin/java

Here’s an example:

# file /usr/local/java/jdk1.6.0_18/bin/java
/usr/local/java/jdk1.6.0_18/bin/java: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped

As you can see, it’s a 32-bit file.

2. Another option, if the Java process is running, is the jinfo command:

# /usr/local/java/jdk1.6.0_18/bin/jinfo -sysprops $PID | grep sun.arch.data.model
Attaching to process ID 31442, please wait…
Debugger attached successfully.
Client compiler detected.
JVM version is 16.0-b13
sun.arch.data.model = 32

As you can see, sun.arch.data.model = 32 means that it’s a 32-bit JVM.

3. A third option is using the -d64 or -d32 flags.

Ex. # /usr/local/java/jdk1.6.0_18/bin/java -d64 -version
Running a 64-bit JVM is not supported on this platform.

# /usr/local/java/jdk1.6.0_18/bin/java -d32 -version
java version “1.6.0_18”
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing)

You can see that it wouldn’t allow the -d64 option as it’s only a 32-bit JVM.

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top