You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Marion, Patrick" <pa...@certive.com> on 2005/10/14 02:06:06 UTC

How can ant detect it is running on a 64 bit machine?

Problem:
	have ant tell me whether I am running on a 64 bit architecture.

I thought the solution was:

	check for the value of the "os.arch" property.

Unfortunately, if I can make something out of the value returned on Windows
("amd64) I can't on Linux (it returns "i386" which is identical to the one
on a 32 bit machine); solaris sparc just returns "sparc".  The only os.*
properties which seem to be available to ant at start time seem to be:
"version", "name", and "arch".

Any suggestion on how to better handle this? 

Thanks.
P.




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How can ant detect it is running on a 64 bit machine?

Posted by Tim Meals <ti...@codeknox.com>.
Patrick --

Although it's not cross-platform, you could get the value of 'uname 
-m'.  On my Gentoo P4 laptop, it's i686 whereas System.getProperty( 
"os.arch" ) gives i386.  Same discrepancies for an Intel EM64T -- uname 
-m gives x86_64, os.arch is amd64.  Then again, I'm using an IBM amd64 
JVM on that machine.

My guess is the 64-bit Intel machine you're running on is using a 32-bit 
JVM.  So, Java will only really return the architecture of the _JVM_, 
which isn't really the OS.  Is a bit of a misnomer on Sun's part.  
Perhaps they should've called the system property jvm.arch.

Best of luck,
Tim Meals
Applications Developer

Marion, Patrick wrote:

>Problem:
>	have ant tell me whether I am running on a 64 bit architecture.
>
>I thought the solution was:
>
>	check for the value of the "os.arch" property.
>
>Unfortunately, if I can make something out of the value returned on Windows
>("amd64) I can't on Linux (it returns "i386" which is identical to the one
>on a 32 bit machine); solaris sparc just returns "sparc".  The only os.*
>properties which seem to be available to ant at start time seem to be:
>"version", "name", and "arch".
>
>Any suggestion on how to better handle this? 
>
>Thanks.
>P.
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How can ant detect it is running on a 64 bit machine?

Posted by Robert Clark <ro...@quest.com>.
On Thursday October 13, 2005 08:06 pm, "Marion, Patrick" 
<pa...@certive.com> wrote:
> Problem:
> 	have ant tell me whether I am running on a 64 bit architecture.
>
> I thought the solution was:
>
> 	check for the value of the "os.arch" property.
>
> Unfortunately, if I can make something out of the value returned on
> Windows ("amd64) I can't on Linux (it returns "i386" which is
> identical to the one on a 32 bit machine); solaris sparc just
> returns "sparc".  The only os.* properties which seem to be
> available to ant at start time seem to be: "version", "name", and
> "arch".

If you are running a Sun (or IBM, I believe) 1.4+ VM. You can check 
the system property "sun.arch.data.model". This will be "32" for a 32 
bit VM and "64" for a 64 bit VM.

For earlier versions of the above JVMs, you could reasonably assume 
that they are 32-bit. 

However, that still means that you have to figure what to do for other 
VMs and platforms.

- Rob

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How can ant detect it is running on a 64 bit machine?

Posted by Jeffrey E Care <ca...@us.ibm.com>.
Here are a couple of ideas:

*use a wrapper script to set a system environment variable, which you can 
access with <property env="..."/>
*write a custom task that can make the determination in Java code
*use <script> to write custom logic (don't know if this is realistic - I 
don't really use <script>)

-- 
Jeffrey E. Care (carej@us.ibm.com)
WebSphere v7 Release Engineer
WebSphere Build Tooling Lead (Project Mantis)


"Marion, Patrick" <pa...@certive.com> wrote on 10/13/2005 
08:06:06 PM:

> Problem:
>    have ant tell me whether I am running on a 64 bit architecture.
> 
> I thought the solution was:
> 
>    check for the value of the "os.arch" property.
> 
> Unfortunately, if I can make something out of the value returned on 
Windows
> ("amd64) I can't on Linux (it returns "i386" which is identical to the 
one
> on a 32 bit machine); solaris sparc just returns "sparc".  The only os.*
> properties which seem to be available to ant at start time seem to be:
> "version", "name", and "arch".
> 
> Any suggestion on how to better handle this? 
> 
> Thanks.
> P.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>