Re: GlueGen tries to load 64 bits libs on 64 bits machines using 32 bits JVM
Posted by Gene on Jan 21, 2012; 4:08am
URL: https://forum.jogamp.org/GlueGen-tries-to-load-64-bits-libs-on-64-bits-machines-using-32-bits-JVM-tp3610342p3677251.html
I ran into this back in JOGL 1 days building an installer to pick 32- or 64-bit DLLs. After much research I wrote the following code which has worked well on thousands of machines to date. The project is welcome to the code and algorithm.
public class DetectJVM {
// Add to this list any Java attribute that, if the key exists in global
// properties, the value contains a 64 if and only if we are running a
// 64-bit JVM, which therefore needs AMD64 format DLLs in Windows.
private static final String keys [] = {
"sun.arch.data.model",
"com.ibm.vm.bitmode",
"os.arch",
};
public static void main (String [] args) {
boolean print = args.length > 0 && "-print".equals(args[0]);
for (String key : keys) {
String property = System.getProperty(key);
if (print) {
System.out.println(key + "=" + property);
}
if (property != null) {
int errCode = (property.indexOf("64") >= 0) ? 64 : 32;
if (print) {
System.out.println("err code=" + errCode);
}
System.exit(errCode);
}
}
}
}