Results 1 to 5 of 5
Thread: retrieve OS architecture
- 08-18-2010, 09:35 PM #1
Member
- Join Date
- Jul 2010
- Posts
- 7
- Rep Power
- 0
retrieve OS architecture
Hi All,
How do I know whether a machine is a 32 bit one or a 64 bit one using java code?
I tried using System.getProperties(os.arch)
But it actually gives the JRE's one rather than the machine's actual one.
i.e. in my 64-bit machine I have 32-bit JRE installed
The os arch value obtained is x86.
Is there a way to do this?
I thought of checking the size of integer?How do we do this in java and will it help?
Thanks in advance
Jith
- 08-19-2010, 03:41 AM #2
Senior Member
- Join Date
- Jul 2010
- Posts
- 124
- Rep Power
- 0
Well, you could use set a String to equal the property, and check if it contains a value:
cheers,Java Code:String s = System.getProperty("os.arch"); if (s.contains("86") || s.contains("64")){ //This is a 64 bit OS } else if (s.contains("i")){ //this is 32 bit. I have it search for 'i' because it could be i386, i586 or i686 } else { //Unknown or other arch }
Crikey
- 08-19-2010, 10:10 AM #3
Member
- Join Date
- Jul 2010
- Posts
- 7
- Rep Power
- 0
Hi Crikey..
I used the same technique which you mentioned..
May be you didnot read my question completely..
When we use System.getpropertes(Os.arch), it actually gives the JRE's bitness.. This is not what i want
I need the actual processor's "bitness" value
Hope that clear my question
Jith
- 08-19-2010, 11:24 AM #4
hi,
System.getProperty("os.arch");
this code always return OS architecture and from your 1st post your OS is x86(32-bit). it didn't mean you PC is 32-bit.
64-bit PC can have 32-bit OS, like you have 32-bit jdk in ur 64-bit PC.
I can't be done by System.getProperty(); and probably not by Java.How do I know whether a machine is a 32 bit one or a 64 bit one using java code?
-regards
- 08-21-2010, 06:52 PM #5
os.arch.data.model property ?
Properties : Java Glossary
but that probably is not going to hint if 64 bit machine when running a 32 bit os.
Kind of platform specific, for example, on linux if you look in the file "/proc/cpuinfo", maybe open it and parse the flags : value, there will be "lm" flag to mean long mode, to mean the CPU is working in 64 bit mode. But that does nothing for you on Windows. Perhaps, try to detect the "C:\Program Files" and separate "C:\Program Files (x86)" folders to infer 64 bit OS.
Similar Threads
-
Question about architecture
By sdmente in forum Advanced JavaReplies: 7Last Post: 07-28-2010, 01:07 PM -
Architecture Rules 2.1.1
By Java Tip in forum Java SoftwareReplies: 0Last Post: 07-11-2008, 02:39 PM -
Architecture Rules 2.1.0
By Java Tip in forum Java SoftwareReplies: 0Last Post: 07-05-2008, 06:18 PM -
Architecture Rules 2.0-rc2
By JavaBean in forum Java SoftwareReplies: 0Last Post: 11-14-2007, 06:27 PM -
Architecture of Any IDE...
By vikki_pu in forum Other IDEsReplies: 5Last Post: 10-30-2007, 01:08 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks