I've been working on this for probably a month now... Basically I can get the Windows version and Service pack level, but the bit isn't accurately determined. The bit is always returned as the bit of the JRE that the code is running on (usually the 32 bit JRE is running, even on 64 bit sytems). Can anyone tell me a way to find the bit of the actual OS that is running, not just the JRE? Or even point me in the right direction? I tried doing this in C and C++, but it's just so complicated that it's not really worth my time to figure it out... Maybe I can just check if there's a folder called "Program Files (x86)" or some roundabout trick like that... it just seems like Microsoft should have made a way to check this without extensive coding in C or C++. Thanks for any help.
This must be a bug in java... why else would os.name and os.patch.level return the actual OS attributes? os.arch only returns the JVM architecture (so how can they call this os.arch?). Anyway, I found a way around this, but so far it's somewhat of a messy solution. I created a C# program that solely runs and then returns the exit code of the architecture (either 32 or 64). This so far has been accurate. Then I just run that bit.exe file from java and read the return code to determine the real arch of the OS. The problem is that it's difficult (for me at least) to run that bit.exe from within the jar file, requiring me to now have the jar file and the exe file alongside one another to properly use my application. I'd rather have a simple java app and move on with my life, but it looks like java isn't really equipped for that yet (again, it doesn't make sense to me, but I'll have to live with it until they improve their OS details features). Anyway, here's my java code so far if anyone is interested (and so you know I'm not just asking for answers, I'm still making progress):
Thanks for the response. Well that will print the size of a pointer to void. Maybe if we got the size of an int... But then we still need to see if it's 4 or 8 bytes and then print (or return) either 32 or 64 respectively. That actually might be pretty helpful to me though because to run any code generated in C# you have to first install the dot net framework (which for me defeats the purpose of this project because you then have to determine if you should install the 32 bit framework out the 64 bit framework...). So I'll definitely try that out, because I think it will work.