-
Notifications
You must be signed in to change notification settings - Fork 19
Java 9 and 32 vs 64 bit #28
Comments
I currently don't have access to a windows machine, do you know what is the way to figure out if 32 or 64 bit are used on jdk9? |
Sure. I don't think you can tell the difference any more on 32-bit vs 64-bit just by checking for the presence of a file as was the case prior to Java 9. However, there's a another way: Regardless of Java version the executable is You can fairly easily determine if the executable is 32 or 64 bit by peeking into it. (I've highlighted the two values you need to check for, the rest you'll never encounter :-)) While this may seem technically complex (no, not really), it is fully document by MS, it is bullet proof, fast and forward and backward compatible. It is fast because you won't have to read much from the file, the info is somewhere in the PE header. Remember to err on the side of caution. Alternatively you can call the native function GetBinaryType using either JNA or JNI but I believe the above is simpler. |
Have a look at the Gist I created: https://gist.github.com/phansson/3160a3f607fd887a2cdf031896115f5c Feel free to copyright it in your own name or whatever. You'll simply use it like this if (WinExeUtils.is64Bit(exeFile)) {
} It is quite simple what it does. No magic. You can use this method for any version of Java. |
The plugin's method for determining if the JVM is 32 bit or 64 bit will not work with Java 9.
In files
RunNetBeansMojo.java
andRunPlatformAppMojo.java
the method is based on testing for the existence ofThis will for sure not work with Java 9.
(btw : the same code is duplicated between the two mojos, so maybe this is an opportunity for a little bit of refactoring?)
The text was updated successfully, but these errors were encountered: