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

前端 未结 12 1802
滥情空心
滥情空心 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:24

    I installed 32-bit JVM and retried it again, looks like the following does tell you JVM bitness, not OS arch:

    System.getProperty("os.arch");
    #
    # on a 64-bit Linux box:
    # "x86" when using 32-bit JVM
    # "amd64" when using 64-bit JVM
    

    This was tested against both SUN and IBM JVM (32 and 64-bit). Clearly, the system property is not just the operating system arch.

提交回复
热议问题