How to get the bit version of java, which user has chosen during installation?
During installation of my application using InstallAnywhere, user has to choose the path of java, which he later wants to use for running the application. Since application requires java 1.8, 32-bit version, when user selects path to java, if version or bit-version doesn't match, user has to be notified. How this can be done?
I believe that you can use os.arch to get the JVM bitness, as it returns different bitness based on the JVM used (ie 32-bit/64bit). It should ideally return the OS architecture but it seems to return the JVM bitness.
You can try this by running a small program in 32-bit/64-bit JVM:
(* Not sure if this has changed in the latest versions of Java)
Hi @UtsabKarmakar ,
Thanks for your reply. As you said, if I run the sample program with this property in eclipse, it gives the bit version of the java which is given in project. But, when I use this property in InstallAnywhere, it always points to the bit-version of java from environment variable. My requirement is to get the bit version, which the user has selected during the installation process.
Well that will be a tricky one, the easy way will be executing process java -d32/-d64 to get the output and then parse it.
Or read the bitness of the java.exe from the PE Header (0x8664 | 0x14c) see: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format. (may be not recommended)
Or running a .jar(where you get the os.arch) from the selected java.exe, but here there is a minor complication of where to store the .jar, as all the payloads will be deployed during installation.