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.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
For a 64bit java version it'll print :
For 32 bit it'll be just
When writing Java code, how do I distinguish between 32 and 64-bit operation?
http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#64bit_detection
The JVM architecture in use can be retrieved using the "os.arch" property:
The "os" part seems to be a bit of a misnomer, or perhaps the original designers did not expect JVMs to be running on architectures they weren't written for. Return values seem to be inconsistent.
The NetBeans Installer team are tackling the issue of JVM vs OS architecture. Quote:
Sample properties from different JVMs all running on 64bit Ubuntu 8.0.4:
32bit IBM 1.5:
64bit Sun 1.6:
64bit GNU 1.5:
(The GNU version does not report the "sun.arch.data.model" property; presumably other JVMs don't either.)
The following code checks the machineType field in any windows executable to determine if it is 32 or 64 bit:
Note that the code has been compacted for brevity...
There might be both 32 bit and 64 bit JVM's available on the system, and plenty of them.
If you already have dll's for each supported platform - consider making a small executable which links and run so you can test if the platform supports a given functionality. If the executable links and run, you can install the corresponding shared libraries.