I used the answer of the following question to determine the systems bit version, which works fine besides on mac osx: How can I check the bitness of my OS using Java?? (J2SE, not os.arch)
String arch = System.getenv("PROCESSOR_ARCHITECTURE");
String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432");
String realArch = arch.endsWith("64")
|| wow64Arch != null && wow64Arch.endsWith("64")
? "64" : "32";
The last line (realArch) gives me a NPE on mac, do you have any idea how I could solve it, that I get the right bit version on mac, too?
UPDATE:
I read the answer wrong, sorry for that. It works fine on windows, mac osx and ubuntu with this little change:
String realArch = System.getProperty("os.arch").endsWith("64")
? "64" : "32";
if (System.getProperty("os.name").startsWith("Windows")) {
String arch = System.getenv("PROCESSOR_ARCHITECTURE");
String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432");
realArch = arch.endsWith("64")
|| wow64Arch != null && wow64Arch.endsWith("64")
? "64" : "32";
}