Reputation: 47
Is there a way to determine the JVM version (32-bit or 64-bit) in C#? I found the following post with a possible way to do this: http://forums.devshed.com/net-development-87/c-net-check-java-version-562395.html It suggests to parse the string returned by the java -version command and look for the version. Is it safe to assume that the following is from the 32-bit version?
java version "1.6.0_24" Java(TM) SE Runtime Environment (build 1.6.0_24-b07) Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)
On a device running a 64-bit JVM I do see the 64-bit word in place of the "Client VM".
Upvotes: 0
Views: 935
Reputation: 51369
The method that you found is appropriate, but you need to remember that a user may have multiple different JVM versions installed, including (on a 64-bit machine) both 32 and 64 bit VMs. The one that runs when you run Java.exe is just the last one on the path.
If you don't see 64-bit in the string, it is probably safe to assume a 32 bit VM. See http://java.sun.com/j2se/versioning_naming.html for the naming convention.
Upvotes: 1