How can I identity whether the installed version of Java is 64 bit
or 32 bit
?

- 11,817
- 4
- 41
- 57

- 153
- 1
- 1
- 4
-
Indeed, at runtime (from within the Java code that is running on the JVM you need to know about) or from scripts that check what's installed on your OS. Depending on the answer of that, two completely different answers are possible ;) – Arjan Tijms Jan 01 '11 at 13:26
-
1I would suggest you write code which doesn't depend on the version installed. Why do you need to know this? – Peter Lawrey Jan 01 '11 at 18:51
3 Answers
Enter java -version on the command line. If it's 64-bits it will say so, otherwise it's 32-bits.
E.g.
64 bits Oracle / Mac OS X
$ java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01-279, mixed mode)
32 bits Oracle / Mac OS X (client)
$ java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
Java HotSpot(TM) Client VM (build 16.3-b01-279, mixed mode, sharing)
32 bits Oracle / Mac OS X (server)
$ java -server -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
Java HotSpot(TM) Server VM (build 16.3-b01-279, mixed mode)
64 bits OpenJDK Ubuntu
$ java -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.1) (6b20-1.9.1-1ubuntu3)
OpenJDK 64-Bit Server VM (build 17.0-b16, mixed mode)
32 bits Soylatte Mac OS X
$ java -version
java version "1.6.0_03-p3"
Java(TM) SE Runtime Environment (build 1.6.0_03-p3-landonf_19_aug_2008_14_55-b00)
Java HotSpot(TM) Client VM (build 1.6.0_03-p3-landonf_19_aug_2008_14_55-b00, mixed mode)
32 bits OpenJDK Mac OS X
$ java -version
openjdk version "1.6.0-internal"
OpenJDK Runtime Environment (build 1.6.0-internal-landonf_17_may_2009_13_58-b00)
OpenJDK Client VM (build 11.0-b17, mixed mode)
64 bits IBM Linux
$ java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build pxa6460sr8fp1-20100624_01(SR8 FP1))
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 Linux amd64-64 jvmxa6460sr8ifx-20100609_59383 (JIT enabled, AOT enabled)

- 37,782
- 12
- 108
- 140
-
$ java -version, this doesn't show me if it is a 32 bit VM or not, on executing the command, i got the following: java version "1.6.0_20" Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing) – Karthick Ragunath Jan 01 '11 at 13:02
-
4Then it's the 32 bit VM ;) If it's 64-bits, it explicitly says so. Same Java version on a 32 bit machine will show: *java version "1.6.0_20" Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065) Java HotSpot(TM) Client VM (build 16.3-b01-279, mixed mode, sharing)* Note that server or client doesn't make the difference. Execute with -server on a 32 bit machine and it will still not say "32-bit" – Arjan Tijms Jan 01 '11 at 13:12
-
is this information included in `java -version` for runtimes from other vendors? – Bozho Jan 01 '11 at 13:27
-
One doesn't know. What the command prints is implementation dependent. At least the Sun JDK (checked Windows/Linux) and Mac OS X JDK (which is a Sun modified version anyway) print this. I quickly checked Soylatte and OpenJDK on 32 bits, and on 32 bits they don't print the number of bits. – Arjan Tijms Jan 01 '11 at 13:32
-
1
You can get the os.arch
property:
String osArch = System.getProperty("os.arch");
This will tell you the architecture of the OS, so not exactly the one of the VM.
Sun's JREs have the following properties (values from my machine) that may be useful:
sun.arch.data.model : 32
sun.cpu.isalist : pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86
But have in mind that these will not work on VMs from other vendors. So you may want to find such properties of other VMs as well, so that you are not vendor-dependent.

- 146,994
- 96
- 417
- 335

- 588,226
- 146
- 1,060
- 1,140
-
With this, am i getting the underlying OS version or the JVM version? – Karthick Ragunath Jan 01 '11 at 13:05
-
-
right, i got a way to identify the JVM version as well. 'System.getProperty("sun.arch.data.model")' thanks for ur information – Karthick Ragunath Jan 01 '11 at 13:08
-
note that this will not work with other VMs by other vendors. So take your time to see their properties for identifying the arch. – Bozho Jan 01 '11 at 13:10
-
@KarthickRagunath Are you sure of the JVM version you're running? Because "os.arch" is intended to return the JVM version, not the underlying OS – arkon May 24 '12 at 10:34
I have both 32-bit and 64-bit versions of Java installed, but java -version only says 64-bit server (mixed mode). So this won't work if you have multiple (and previous) versions of Java installed.
There's another way to check I just realized: for Windows, if you have the 32-bit version installed then it will be in c:\Program Files (x86)\java\jre7 (or whatever the version of Java is installed). I see I also have a jre6 folder, which is a bit disconcerting because I thought I had already uninstalled it.
And for the 64-bit version, it will be in c:\Program Files\java (where all the 64-bit applications are installed).

- 21
- 2