32bit 64bit jvm

本文介绍了如何通过Java System Property 'sun.arch.data.model'来判断运行环境是32位还是64位的JVM。提供了获取此信息的方法,并讨论了在Java代码中区分不同位数操作的重要性。
This "detail" is not abstracted away when interacting with the Java Native Interface. 32-bit DLLs can't be loaded with a 64-bit JVM (and vice versa). So this is quite essential information for anyone using JNI. It's a pity that there seems to be no portable way to obtain this info. One way is to first try loading a 32-bit version of the DLL, and if it fails, try the 64-bit version, etc. Ugly! –  Joonas Pulakka Apr 30 '10 at 7:17

---------------------------------------------------------------------------------------------------------------------------------------------------

 

Sun has a Java System property to determine the bitness of the JVM: 32 or 64:

sun.arch.data.model=  
sun
.arch.data.model=  

You can use

.getProperty()  

to determine if its 32/64 from the program.

From the sun.docs:

When writing Java code, how do I distinguish between 32 and 64-bit operation?

There's no public API that allows you to distinguish between 32 and 64-bit operation. Think of 64-bit as just another platform in the write once, run anywhere tradition. However, if you'd like to write code which is platform specific (shame on you), the system property sun.arch.data.model has the value "32", "64", or "unknown".

The only good reason is if your java code is dependent upon native libraries and your code needs to determine which version (32 or 64bit) to load on startup.

Note by me : 这个仅在HotSpot JVM上可用

------------------------------------------------------------------------------------------------------------------------------------------------

System.out.println(System.getProperty("java.vm.name")); 
Note by me : 这个不好说,也许能返回带有64bit的标识,

-----------------------------------------------------------------------------------------------------------------------------------------------

Copy from ServerFault:

4 down vote accepted

Here (from the Sun release notes) is the answer I was looking for, at least for how to ensure the JDK server is up and running:

jre\bin\server\

On Microsoft Windows platforms, the JDK includes both the Java HotSpotTM Server VM and Java

 HotSpotTM Client VM. However, the JRE for Microsoft Windows platforms includes only the Java HotSpotTM Client VM. Those wishing to use the Java HotSpotTM Server VM with the JRE may copy the JDK's jre\bin\server folder to a bin\server directory in the JRE. Software vendors may redistribute the Java HotSpotTM Server VM with their redistributions of the JRE.

---------------------------------------------------------------------------------------------------------------------------------------------------

http://stackoverflow.com/questions/198577/real-differences-between-java-server-and-java-client

http://stackoverflow.com/questions/1803075/crowdsourcing-a-complete-list-of-common-java-system-properties-and-known-values

http://stackoverflow.com/questions/1833129/how-to-make-sure-im-using-the-server-jvm

转载于:https://www.cnblogs.com/diyunpeng/archive/2011/12/27/2303957.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值