如何检测安装了何种的JRE - 32位与64位 [英] How do I detect which kind of JRE is installed -- 32bit vs. 64bit

查看:464
本文介绍了如何检测安装了何种的JRE - 32位与64位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装过程中有一个NSIS安装,我需要检查哪些JRE(32位VS 64位)被安装在系统上。我已经知道我可以检查系统属性 sun.arch.data.model ,但这是特定于Sun的。我不知道是否有这一个标准的解决方案。

During installation with an NSIS installer, I need to check which JRE (32bit vs 64bit) is installed on a system. I already know that I can check a system property "sun.arch.data.model", but this is Sun-specific. I'm wondering if there is a standard solution for this.

推荐答案

在使用JVM体系结构可以使用检索的os.arch 属性:

The JVM architecture in use can be retrieved using the "os.arch" property:

System.getProperty("os.arch");

在操作系统的部分似乎是有点用词不当,或者原设计者没有想到的JVM要在架构他们并没有书面运行。返回值似乎不一致

在NetBeans安装团队解决问题 JVM的VS OS架构。报价:

The NetBeans Installer team are tackling the issue of JVM vs OS architecture. Quote:

64位:Java和系统

履带作为问题143434

目前,我们使用的x64 JVM的位   确定系统(并且因此   Platform.getHardwareArch())是64位的   或不。这是因为绝对错误   有可能上运行32位的JVM   64位系统。我们应该找到一个   解决方案检查OS真正的64位数   如果在32位JVM上运行的。

Currently we using x64 bit of JVM to determine if system (and thus Platform.getHardwareArch()) is 64-bit or not. This is definitely wrong since it is possible to run 32bit JVM on 64bit system. We should find a solution to check OS real 64-bitness in case of running on 32-bit JVM.

      
  • 对于Windows可以使用WindowsRegistry.IsWow64Process()来完成
  •   
  • 为Linux - 通过检查'uname -m输出/ -p== x86_64的
  •   
  • 适用于Solaris可以使用例如做isainfo是否-b
  •   
  • 适用于MacØSX能 T使用的uname参数来完成,大概也可以是   通过创建的64位二进制解决   并执行该平台上...   (不幸的是,这并没有工作:(   我已经创建的二进制只有x86_64的   和PPC64拱,这是成功的   老虎执行。)
  •   
  • 对于通用Unix的支持 - 目前尚不清楚,以及...可能检查   对于同一的uname -m / -p/使用getconf   LONG_BIT'并与一些比较它   可能的64位值(x86_64的,64位,   AMD64,IA64)。
  •   
  • for Windows it can be done using WindowsRegistry.IsWow64Process()
  • for Linux - by checking 'uname -m/-p' == x86_64
  • for Solaris it can be done using e.g. 'isainfo -b'
  • for Mac O SX it cant be done using uname arguments, probably it can be solved by creating of 64-bit binary and executing on the platform... (unfortunately, this does not work:( Ive created binary only with x86_64 and ppc64 arch and it was successfully executed on Tiger..)
  • for Generic Unix support - it is not clear as well... likely checking for the same 'uname -m/-p' / 'getconf LONG_BIT' and comparing it with some possible 64-bit values (x86_64, x64, amd64, ia64).


这是不同的JVM在64位的Ubuntu 8.0.4所有正在运行的示例属性:

Sample properties from different JVMs all running on 64bit Ubuntu 8.0.4:

32位IBM 1.5:

32bit IBM 1.5:

java.vendor=IBM Corporation
java.vendor.url=http://www.ibm.com/
java.version=1.5.0
java.vm.info=J2RE 1.5.0 IBM J9 2.3 Linux x86-32 j9vmxi3223-20061001 (JIT enabled)
J9VM - 20060915_08260_lHdSMR
JIT  - 20060908_1811_r8
GC   - 20060906_AA
java.vm.name=IBM J9 VM
java.vm.specification.name=Java Virtual Machine Specification
java.vm.specification.vendor=Sun Microsystems Inc.
java.vm.specification.version=1.0
java.vm.vendor=IBM Corporation
java.vm.version=2.3
os.arch=x86
os.name=Linux
os.version=2.6.24-23-generic
sun.arch.data.model=32

64日1.6:

64bit Sun 1.6:

java.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi
java.version=1.6.0_05
java.vm.info=mixed mode
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
java.vm.specification.name=Java Virtual Machine Specification
java.vm.specification.vendor=Sun Microsystems Inc.
java.vm.specification.version=1.0
java.vm.vendor=Sun Microsystems Inc.
java.vm.version=10.0-b19
os.arch=amd64
os.name=Linux
os.version=2.6.24-23-generic
sun.arch.data.model=64

64位GNU 1.5:

64bit GNU 1.5:

java.vendor=Free Software Foundation, Inc.
java.vendor.url=http://gcc.gnu.org/java/
java.version=1.5.0
java.vm.info=GNU libgcj 4.2.4 (Ubuntu 4.2.4-1ubuntu3)
java.vm.name=GNU libgcj
java.vm.specification.name=Java(tm) Virtual Machine Specification
java.vm.specification.vendor=Sun Microsystems Inc.
java.vm.specification.version=1.0
java.vm.vendor=Free Software Foundation, Inc.
java.vm.version=4.2.4 (Ubuntu 4.2.4-1ubuntu3)
os.arch=x86_64
os.name=Linux
os.version=2.6.24-23-generic

(GNU版本不报告sun.arch.data.model财产; presumably其他JVM没有任何)

(The GNU version does not report the "sun.arch.data.model" property; presumably other JVMs don't either.)

这篇关于如何检测安装了何种的JRE - 32位与64位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆