How can I tell if I'm running in 64-bit JVM or 32-bit JVM (from within a program)?

前端 未结 12 1995
滥情空心
滥情空心 2020-11-22 09:39

How can I tell if the JVM in which my application runs is 32 bit or 64-bit? Specifically, what functions or properties I can used to detect this within the program?

12条回答
  •  没有蜡笔的小新
    2020-11-22 10:12

    On Linux, you can get ELF header information by using either of the following two commands:

    file {YOUR_JRE_LOCATION_HERE}/bin/java
    

    o/p: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), for GNU/Linux 2.4.0, not stripped

    or

    readelf -h {YOUR_JRE_LOCATION_HERE}/bin/java | grep 'Class'
    

    o/p: Class: ELF64

提交回复
热议问题