aspose file tools
The moose likes Java in General and the fly likes How to check the jdk bit version (32bit or 64 bit) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How to check the jdk bit version (32bit or 64 bit)" Watch "How to check the jdk bit version (32bit or 64 bit)" New topic
Author

How to check the jdk bit version (32bit or 64 bit)

Vardan Negi
Greenhorn

Joined: Jul 12, 2010
Posts: 15
Hi Guys,
I have a query regarding JDK bit version (64 bit or 32 bit). Not sure how to check the bit version in Windows, solaris and other O/S.

Output for java -version is as follows
java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) Client VM (build 1.5.0_16-b02, mixed mode, sharing)

Please help.

Thanks,
Vardan.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19230

Check System.getProperty("os.arch"). This will print out something like x86 for a 32 bit JVM. System.getProperty("sun.arch.data.model") also seems to be doing the job. But keep in mind, these (most likely) return the value for the JVM - a 32 bit JVM on a 64 bit OS will probably still be identified as 32 bit.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12950
    
    3

The output that you show from java -version is from a 32-bit version. If it is 64-bit, you'll see something like "64-bit Server VM" in there instead of "Client VM".


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Niranjan Welankiwar
Greenhorn

Joined: Mar 28, 2012
Posts: 4
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.

John Jai
Bartender

Joined: May 31, 2011
Posts: 1778
Niranjan Welankiwar wrote: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.


When I tried on my 32 bit system I get following output. Not able to see quoted output "This Java instance does not support a 64-bit JVM. Please install the desired version."
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19230

Apparently this flag was added in Java 7. When I try it with a Java 6 JVM it fails, with a Java 7 JVM I get the specified output.
Tulasi Kadali
Greenhorn

Joined: Dec 23, 2012
Posts: 1
Hi Vardhan,

In solaris you can check whether java is 64bit by using the following command
================================================
#truss -t exec java -d64 -version

execve("/usr/jdk/instances/jdk1.5.0/bin/java", 0xFFBFFDDC, 0xFFBFFDEC)
argc = 3

execve("/usr/jdk/instances/jdk1.5.0/bin/sparcv9/java", 0x00031E18,
0x00032ADC)

argc = 2

java version "1.5.0_06"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)

Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_06-b05, mixed mode)
=============================================
The last line should give 64-Bit or 32-bit Java.

CHEERS,
RAMU KADALI



Vardan Negi wrote:Hi Guys,
I have a query regarding JDK bit version (64 bit or 32 bit). Not sure how to check the bit version in Windows, solaris and other O/S.

Output for java -version is as follows
java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) Client VM (build 1.5.0_16-b02, mixed mode, sharing)

Please help.

Thanks,
Vardan.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to check the jdk bit version (32bit or 64 bit)
 
Similar Threads
Experience on Mac OS X for JavaEE Development
Eclipse 3.2.0:JVM Terminated
Upgrading from Java SE to Java EE
Helping Setting JDK 1.6 in Leopard
Profiling - Heap & GC between Linux and Windows