1

I want to send a jar to some people for testing my software but I need that the jar is launched on a 32bit jvm. How can I verify automatically that the 32 bit jvm is installed and to be sure that the jar is launched with the right jvm?
I want to avoid to ask people to do all manually because they are not technical guys.
Can you help me?


******** SOLUTIONS ******
I have found two type of solutions that i want to share with you: 1) I have discovered that C:\Windows\SysWoW64 and C:\Windows\system32 contain the last installed version of the java.exe. So, ones could write a .bat that verifies which is the 32bit jvm for launching the code 2) Use the java code described in an other post for generating the proper .bat

Community
  • 1
  • 1
Antonio
  • 29
  • 5
  • The link that Stanislav provided in his answer will give you the bit size. Is there a reason that you need 32bit? Maybe a better question is how to remove reliance on a particular architecture. – markbernard Nov 06 '14 at 18:34
  • I need to use 32bit jvm because my software uses some dll compiled for 32bit platform. 64 jvm can't load 32bit version, for this reason it's mandatory that they use a 32bit dll. So, i want to try a solution for automatically launch my software with the 32bit version – Antonio Nov 07 '14 at 09:03

1 Answers1

0

As far as I know there is no simple way to achieve that. First guess is, of course, the %JAVA_HOME%. But it is most likely not set on the PC of "not technical guy", so let's skip it.

I believe there is a tricky way with Windows registry that could work.

If Java was installed with an installer (not just manual unpack) it will have some registry entries. On my PC I've found key HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.8.0_25\JavaHome that points to my Java installation. There is also JDK keys nearby. There are multiple versions that can be installed on the same machine so it is better to collect all this keys (both jre and jdk in both HKLM and HKCU) and try to find one that points to the 32bit version. And if one has non-Oracle Java on his PC then registry keys will most likely have another path (if even exist).

When you found java installation there are many ways to check if it is 32 or 64 bit. Take a look at this SO question.

Community
  • 1
  • 1
Stanislav Lukyanov
  • 2,147
  • 10
  • 20
  • Almost 10 years later, many people now use AdoptOpenJDK (since renamed Eclipse Adoptium) instead of Oracle JRE/JDK. `reg query "HKLM\SOFTWARE\AdoptOpenJDK" /s` or `reg query "HKLM\SOFTWARE\Eclipse Adoptium" /s`. On a 64-bit machine, if you need 32-bit you'll want to look under `WOW6432Node` – Simon Kissane Jun 12 '23 at 07:40