Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

How to detect CPU architecture/bitmode (32-bit vs. 64-bit) for Linux

Thread view: 
bfische - 15 Nov 2005 01:02 GMT
Hi List members,

I have been trying to develop some code to figure out if a system is 32
or 64-bits.
I first thought about checking for the value of the Java System
Property "os.arch" but that doesn't help as it doesn't specify the
"bitness" of the processor.

I need to differentiate between a Linux on x86-32 bit or x86-64
(processor can be Intel or AMD) but I can't figure ou how.

uname -p seems to work (gives i686) but I am not sure this will always
return this (I don't have an AMD but I assume it will return a
different value).

Is there an OS command that print the hardware bit mode? (something
like getconf HARDWARE_BITMODE on AIX).

Thanks
Carl - 15 Nov 2005 01:58 GMT
> Hi List members,
>
[quoted text clipped - 15 lines]
>
> Thanks

bfische,

The i686 you noticed in the output of uname does not necessarily
indicate that the processor is or is not 64bit. Furthermore, the '-p'
switch is a non-standard option for the uname command.
http://www.opengroup.org/onlinepubs/007908799/xcu/uname.html

You may want to look into parsing the contents of the /proc/cpuinfo
file, though this is far from a portable solution and may be implemented
differently in different platforms/distros.

Just out of curiosity, why would you want to know the processor type in
java?

Carl.
bfische - 24 Nov 2005 21:32 GMT
Hi Carl,

the reason why I am trying to detect the bitmode of the kernel is
because I am writing an installer. Based on the OS Kernel bitmode,
different set of libraries need to be laid down on the system.

it seems like the uname -m actually gives x86_64 when it is an x86
processor 64 bits (even for AMD processor). That's what I am using. I
hope it will work on all Linux platforms.

> > Hi List members,
> >
[quoted text clipped - 31 lines]
>
> Carl.
Thomas Fritsch - 15 Nov 2005 03:18 GMT
> I have been trying to develop some code to figure out if a system is 32
> or 64-bits.
> I first thought about checking for the value of the Java System
> Property "os.arch" but that doesn't help as it doesn't specify the
> "bitness" of the processor.
On my platform (Java 1.5.0, WinXP (32bit)) there is a java system property
 sun.arch.data.model=32
I suspect this gives the "bitness" of the CPU.
(But be warned: You will enter the area of undocumented Sun-features)

Signature

"TFritsch$t-online:de".replace(':','.').replace('$','@')

"." - 15 Nov 2005 17:58 GMT
> > I have been trying to develop some code to figure out if a system is 32
> > or 64-bits.
[quoted text clipped - 5 lines]
> I suspect this gives the "bitness" of the CPU.
> (But be warned: You will enter the area of undocumented Sun-features)

This will not give you the size of the CPU. This will give you the size of
the JVM. Just to confirm this, I just tried on an HP-UX running on an
Itanium2 (64 bit CPU) using a 32-bit JVM and sun.arch.data.model=32.

Signature

Send e-mail to: darrell dot grainger at utoronto dot ca

Roedy Green - 15 Nov 2005 06:30 GMT
>Is there an OS command that print the hardware bit mode? (something
>like getconf HARDWARE_BITMODE on AIX).
try running wassup on a 64 bit machine to dump all the system
properties or write a little program to do that. See what turns up.
http://mindprod.com/applets/wassup.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.