This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
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: 19656
    
  18

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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: 1776
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: 19656
    
  18

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.
Ashsih khurana
Greenhorn

Joined: Jul 20, 2013
Posts: 4
if it is upto only checking of jdk bit version then we are ok , but whenever there is a question of chosing one of them then we should know the pros and cons of each one over other

I just want to add little extra in it - generally people prefer to switch over 64 but JVM when the existing heap space (1.5 to 1.8 M varies OS to OS) size provided by 32 bit JVM is not suffice for their application , but these days it is very common that people are migrating to 64 bit without understanding the requirement of applications.

http://lotusmediacentre.com/difference-between-32-bit-and-64-bit-jvm-choose-wisely/
 
 
subject: How to check the jdk bit version (32bit or 64 bit)
 
Similar Threads
Experience on Mac OS X for JavaEE Development
Profiling - Heap & GC between Linux and Windows
Upgrading from Java SE to Java EE
Helping Setting JDK 1.6 in Leopard
Eclipse 3.2.0:JVM Terminated