Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Vardan Negi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15484
43
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
Niranjan Welankiwar
Greenhorn
Posts: 4
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic