I am writing an executable from a PowerShell script that needs to put the proper version of Java3D onto the client computer. By proper version, I mean that when the user opens CMD and types ‘java -version’, it gives 32 or 64 bit. I need to choose the dll files for the right architecture.
The problem is, I have found a test case of a 64-bit W7 system with both 32-bit and 64-bit JDK installed. Only the 64-bit version is included in the PATH environment variable. However, when I run my batch script or executable and echo java -version, the 32-bit java comes up. As such, it installs the 32-bit dlls, and when the user goes to the cmd it uses 64-bit so it is not compatible.
Since the 32-bit JDK is not included in the PATH variable, why is the script running 32-bit java and where is it getting this link?
Google Chrome and Firefox are still 32-bit applications under a 64-bit Windows OS, so you are probably executing a 32-bit java installed by them under SysWOW64 – specially if you are installing your application using Java Web Start running inside one of these browsers.
I had the exact same problem, and I’ve implemented a system-wide search for installed javas, so that I can create a batch file that calls the exact java.exe with the proper bitness.
This is what you need:
You will also need the updated WinRegistry.java to read values from both the from 32-bits and 64-bits sections of the windows registry: https://stackoverflow.com/a/11854901/828681
I’m not usually a java programmer, so my code probably does not follow java conventions. Sue me.
Here are the results of JavaFinder.findJavas() on my Win 7 64-bits machine:
Note there’s a 32-bit java.exe under SysWOW64 – and it will get called by the web starter when running inside Chrome or Firefox since they are 32-bit applications – unless you use the JavaFinder to find a properly bitted java.exe and use it’s full path.