यहां एक ऐसा उत्तर है जो काम करता है (मैंने कुबंटू 64, डेबियन 32, विंडोज 2000 और विंडोज एक्सपी पर परीक्षण किया) बाहरी या वैकल्पिक एएनटी निर्भरताओं की आवश्यकता के बिना। यह @ फ़ैटिपस के उत्तर पर आधारित था।
<project name="FindArchitecture" default="check-architecture" basedir=".">
<!-- Properties set: unix-like (if it is unix or linux), x64 (if it is 64-bits),
register- size (32 or 64) -->
<target name="check-architecture" depends="check-family,check-register" >
<echo>Register size: ${register-size}</echo>
<echo>OS Family: ${os-family}</echo>
</target>
<target name="check-family" >
<condition property="os-family" value="unix" else="windows">
<os family="unix" />
</condition>
<condition property="unix">
<os family="unix" />
</condition>
</target>
<target name="check-register" depends="reg-unix,reg-windows">
</target>
<!-- Test under GNU/Linux -->
<target name="reg-unix" if="unix">
<exec dir="." executable="uname" outputproperty="result">
<arg line="-m"/>
</exec>
<!-- String ends in 64 -->
<condition property="x64">
<matches string="${result}" pattern="^.*64$"/>
</condition>
<condition property="register-size" value="64" else="32">
<isset property="x64"/>
</condition>
</target>
<!-- Test under MS/Windows-->
<target name="reg-windows" unless="unix">
<!-- 64 bit Windows versions have the variable "ProgramFiles(x86)" -->
<exec dir="." executable="cmd" outputproperty="result">
<arg line="/c SET ProgramFiles(x86)"/>
</exec>
<!-- String ends in "Program Files (x86)" -->
<condition property="x64">
<matches string="${result}" pattern="^.*=.*Program Files \(x86\)"/>
</condition>
<condition property="register-size" value="64" else="32">
<isset property="x64"/>
</condition>
</target>
</project>
स्रोत
2012-01-23 17:04:55
धन्यवाद, यह सबसे स्वच्छ दृष्टिकोण की तरह लगता है। कोशिश करेंगे। –
सावधान - $ {os.arch} केवल आपको जेवीएम की बिट-नेस बताता है, मंच नहीं। @ फ़ैटिपस का उत्तर देखें। –
पता करने के लिए अच्छा - धन्यवाद –