How to determine 32-bit or 64-bit version of java on Windows?

Hi there,

How do I determine 32-bit or 64-bit version of java on Windows?
Just run   java -version  and see if 64-bit appears?

Thanks.

asugriAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
for_yanCommented:
probably
java -d64 -version is the way
At least on my 32 bit it complains
0
Hugh McCurdyCommented:
Here's what happens if I try for_yan's suggestion on 32bit Linux

$ java -d64
Running a 64-bit JVM is not supported on this platform.

I can test on 64-bit windows if you request it.  (I have to reboot so I'll want a request before I bother).
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

for_yanCommented:
No it looks like -d64 works only on Solaris not on Windows

It lloks like you have to do it from java program using System.getProperty("sun.arch.data.model")

I also thought that default installation directory of java on Windows is named differently, but of vourse one may
install it not in the default directory
0
for_yanCommented:
I am also wondering - on 32bit machine when
I go say to -Xmx1800M - it writes not enough memory

C:>java -Xmx1800M -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

Does it depeden on the machine? Probably not as I have more memory.

So maybe 64bit would allow more?
so it is worth trying on 64bit:

java -Xmx2000M -version

0
Hugh McCurdyCommented:
Not just Solaris.  Linux too.  But then it's likely not that different.  I'll reboot and test.
0
for_yanCommented:
Yes, someone writes there, that -d64 does not work on windows
and in the description of java switches for Solaris they mention that -d64 should work.
Perhaps also works on Linux
0
Hugh McCurdyCommented:
I tested Linux & Win7.  I couldn't figure out how to determine # bits in Win7 even after trying different things.  I'm going to have to give up.

My guess, from the lack of documentation, is it doesn't matter much.
0
for_yanCommented:
how about
java -Xmx2000M -version
in case of 64bit ?
0
CEHJCommented:
In what context do you want to find out - in a script, inside a java app ..?
0
for_yanCommented:

in java program it should be doable with this
 System.getProperty("sun.arch.data.model")

0
CEHJCommented:
Yes - you mentioned that already...
0
gordon_vt02Commented:
Yes and no to your question about java -version.  It will report the version for whichever JDK is first on your PATH, and it is possible and likely that you have both the 64- and 32-bit versions installed, especially since most browsers are 32-bit and would require the 32-bit Java Plugin.

If you run java -version and 64-bit appears, yes, you have a 64-bit JDK installed.  If it doesn't, check in c:\Program Files\Java and see if there is a JDK installed there.  If so, try going to that JDK's bin directory and running .\java.exe -version and see if it gives you 64-bit.  If not, you only have the 32-bit installed.

A simple visual check might tell you as well -- the default location for JDK installs on 64-bit Windows is:

32-bit: c:\Program Files (x86)\Java\<jdk|jre_version>
64-bit: c:\Program Files\Java\<jdk|jre_version>
0
asugriAuthor Commented:

java -d64 does not work on Windows.
java -Xmx2000M -version  to test memory limit is interesting.

We are developing a package using java.  This package uses a dll file.  
32-bit java needs 32-bit dll and 64-bit java needs 64-bit dll.   We are
planning to test out version of java from InstallShield and determine
which dll to provide.   But I think System.getProperty("sun.arch.data.model")
is good since I just load different dll based on value returned by
System.getProperty("sun.arch.data.model").

Thanks a lot for the help.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.