How to Tell If I'm Running in 64-Bit Jvm or 32-Bit Jvm (From Within a Program)

How can I tell if I'm running in 64-bit JVM or 32-bit JVM (from within a program)?

You retrieve the system property that marks the bitness of this JVM with:

System.getProperty("sun.arch.data.model");

Possible results are:

  • "32" – 32-bit JVM
  • "64" – 64-bit JVM
  • "unknown" – Unknown JVM

As described in the HotSpot FAQ:

When writing Java code, how do I distinguish between 32 and 64-bit operation?

There's no public API that allows you to distinguish between 32 and 64-bit operation. Think of 64-bit as just another platform in the write once, run anywhere tradition. However, if you'd like to write code which is platform specific (shame on you), the system property sun.arch.data.model has the value "32", "64", or "unknown".

An example where this could be necessary is if your Java code depends on native libraries, and you need to determine whether to load the 32- or 64-bit version of the libraries on startup.

How to find if java.exe is 32-bit or 64-bit?

You can run C:\ProgramData\Oracle\Java\javapath\java.exe -version. Among the details it prints out, you should see whether it's a 32 or 64 bit version.

A 32 bit version will return something about a "Client VM" or "Server VM", and a 64 bit version will state so explicitly.

E.g., the output of my machine (admittedly, a Fedora 25, but the principle should stand):

openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-b14)
OpenJDK 64-Bit Server VM (build 25.121-b14, mixed mode)

How do I detect whether 32-bit Java is installed on x64 Windows, only looking at the filesystem and registry?

I tried both the 32-bit and 64-bit installers of both Oracle and IBM Java on Windows, and the presence of C:\Windows\SysWOW64\java.exe seems to be a reliable way to determine that 32-bit Java is available. I haven't tested older versions of these installers, but this at least looks like it should be a reliable way to test, for the most recent versions of Java.

how can I check whether on which mode(32 or 64 bit)is java runtime version is running

Your JRE mode depends on the browser mode you are running. Check this link to know about your browser version. That will be the version of your browser JRE. Otherwise if you are using Windows 7 you can check it by going to control panel and look there for Java icon. It will be mentioned there. If you are using XP, most probably the version is 32 bit.

Find out on which Java bit version my java application is running (Solution required in C# and Java)

Use SystemUtils class from org.apache.commons.lang :

String bit = System.getProperty("sun.arch.data.model"); //64
// commons-lang
String javaVersion = SystemUtils.JAVA_VERSION; //1.7.0_71
String jreVersion = SystemUtils.JAVA_RUNTIME_VERSION; //1.7.0_71-b14

running 32 bit jvm alongside 64 bit jvm in eclipse

Download and install a 32-bit JRE (or JDK) on your system.

Find your Launch Configuration (Run As-> Run Configurations...) under Java Application branch.

Go to the JRE tab and select Alternate JRE. Click on Installed JREs... button, add your 32-bit JRE and select it.



Related Topics



Leave a reply



Submit