|
|
Welcome to the Java Forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
- have access to post topics
- communicate privately with other members (PM)
- not see advertisements between posts
- have the possibility to earn one of our surprises if you are an active member
- access many other special features that will be introduced later.
Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.
|
|

06-10-2008, 01:51 PM
|
|
Member
|
|
Join Date: Jun 2008
Posts: 9
|
|
|
32 bit machine or 64 bit machine
Hi All,
Is there any way that java can find out whether it is running on 64bit architecture or 32 bit?
I have searched net and found two possible workarounds:
boolean is64bit;
String osArch = System.getProperty("os.arch").toLowerCase();
is64bit = osArch.indexOf("64") >= 0;
OR
String bits = System.getProperty("sun.arch.data.model", "?");
if (bits.equals("64")) {
is64bit = true;
}
else if (bits.equals("?")) {
// probably sun.arch.data.model isn't available
// maybe not a Sun JVM?
// try with the vm.name property
is64bit = System.getProperty("java.vm.name").toLowerCase().i ndexOf("64") >= 0;
}
// probably 32bit
else
is64bit = false;
but both of them not working in my case. (Vista 64 bit and XP 64 bit).
Depending on the architecture I have to browse some different folders.
Is there any robust method to find out the architecture of the machine?
Thanks in anticipation,
Kapil
|
|

06-11-2008, 04:44 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
|
|
|
Did you try to get the model using sun.arch.data.model property? It gives the data model/data transfer model.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on September 4, 2008)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

06-11-2008, 08:25 AM
|
|
Member
|
|
Join Date: Jun 2008
Posts: 9
|
|
|
Thanks Eranga for your reply.
I have already tried:
String bits = System.getProperty("sun.arch.data.model", "?");
if (bits.equals("64")) {
is64bit = true;
}
.....
but this explains the JVM type 64 bit or 32 bit.
Isn't there anyway to find out the processor type ( 64 or 32 ).
I thought of getting output of dos command systeminfo to get the processor type
System type: X86-based PC/x64-based PC
Is there any other workaround?
Thanks,
Kapil
|
|

06-11-2008, 09:41 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
|
|
|
Really, I think it related to OS. Anyway I have one idea, that OS bit model and H/W bit model should be same right?
If so, we can find the OS bit model, and use it to processing.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on September 4, 2008)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

06-11-2008, 10:52 AM
|
|
Member
|
|
Join Date: Jun 2008
Posts: 9
|
|
|
Eranga,
Can you help me with finding "OS bit model" using java?
How can I find this?
Thanks,
Kapil
|
|

06-11-2008, 11:01 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
|
|
|
There should be a system property to find this. Can't we find such a one.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on September 4, 2008)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

06-17-2008, 02:18 PM
|
|
Member
|
|
Join Date: Jun 2008
Posts: 9
|
|
|
Hi Eranga,
Actually I was testing the above two workarounds with a jar file. I was double clicking the jar and was not able to get the output for os.arch and sun.arch.....
But when I ran the jar from command prompt by using command
java -jar -cp . Filename.jar ,
both of these methods are showing proper results for 64 bit machine. Can somebody explain why is this so ?
Thanks,
Kapil
|
|

06-18-2008, 05:04 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
|
|
|
Quite similar question going on your another thread. I'll discussed it there.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on September 4, 2008)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

06-22-2008, 05:13 AM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Posts: 209
|
|
|
You could always exec to some shell/os command and parse it.
But I know of no way to tell if you are running on a 64 bit processor that happens to be running a 32 bit OS. And these days, it is safe to assume that most 64 bit AMD/Intel processors are running a 32 bit OS.
More importantly, isn't the point of Java to make hardware implementation details unimportant?
|
|

06-23-2008, 07:35 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
|
|
Originally Posted by fishtoprecords
More importantly, isn't the point of Java to make hardware implementation details unimportant?
This is interesting for me. Even me, never worried about such h/w implementations on working with Java. And also I never comes with such issues before.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on September 4, 2008)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

06-23-2008, 07:46 AM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Posts: 209
|
|
|
Part of the reason that Java defines 'long' and Long separate from int and Integer is to make the language independent of the processor. A proper Java JVM will execute the code and get the right answer on a 8 bit, 32 bit or 64 bit machine.
A lot of embedded systems are 8 bit processors, or 16, so in general its not safe to assume that you have 32 or 64 bits.
Long ago, there were many more flavors, systems with 7 bit characters, or 10 six bit characters, per "word" of memory. Most folks don't remember that stuff, since all PCs used the IBM mainframe convention of 8 bits per byte, and byte-based memory.
With network protocols, you have to worry about big-endian and little-endian, but internal register size is rarely an issue these days.
I guess that if you really wanted to have an array of 5gb of data, you would care, since a 32 bit machine can only address 4gb.
|
|

06-23-2008, 07:54 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
|
|
Ya I agreed with you pal. Well said it. 
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on September 4, 2008)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

06-23-2008, 01:58 PM
|
 |
Senior Member
|
|
Join Date: May 2008
Posts: 276
|
|
Hi folks,
This is interesting to find out something new other than core java as we do always.
Kapil try this out:
System.getProperties().list(System.out);
The above stmt prints u some info related to OS such as version architecture n all.
If that is what u dont want then use JNI(Java native Interface), i am nt sure about its API's.
If taht wouldnt work out, the last thing u can do is find out a command line that will give u this information and java always provides u the way to execute them..
Hope ur problem is solved. 
__________________
To finish sooner, take your own time....
Nivedithaaaa
|
|

06-24-2008, 04:29 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
|
|
|
I already do it and for me, there is no such a related option we can use. I found the h/w architecture and try to involve with it.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on September 4, 2008)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|