Maven: Finding out whether running in a 32 or a 64 bit JVM

微笑、不失礼 提交于 2019-12-23 09:30:12

问题


How can I enable or disable a maven profile based on whether the VM that is executing maven is a 32 bit or a 64 bit JVM ?

I tried this:

<activation>
   <os>
       <arch>x86</arch>
   </os>
 </activation>

or amd64 respectively to detect a 32/64 bit VM, but this fails on a 32 bit VM running on a 64 bit Windows as it activates the 64 bit profile.


回答1:


In a Sun VM, check for the system property sun.arch.data.model

<profiles>
<profile>
  <id>32bitstuff</id>
  <activation>
    <property>
      <name>sun.arch.data.model</name>
      <value>32</value>
    </property>
  </activation>
</profile>

<profile>
  <id>64bitstuff</id>
  <activation>
    <property>
      <name>sun.arch.data.model</name>
      <value>64</value>
    </property>
  </activation>
</profile>

</profiles>

Reference:

  • HotSpot FAQ


来源:https://stackoverflow.com/questions/2854882/maven-finding-out-whether-running-in-a-32-or-a-64-bit-jvm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!