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

前端 未结 12 1779
滥情空心
滥情空心 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 09:58

    Just type java -version in your console.

    If a 64 bit version is running, you'll get a message like:

    java version "1.6.0_18"
    Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
    Java HotSpot(TM) 64-Bit Server VM (build 16.0-b13, mixed mode)
    

    A 32 bit version will show something similar to:

    java version "1.6.0_41"
    Java(TM) SE Runtime Environment (build 1.6.0_41-b02)
    Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode, sharing)
    

    Note Client instead of 64-Bit Server in the third line. The Client/Server part is irrelevant, it's the absence of the 64-Bit that matters.

    If multiple Java versions are installed on your system, navigate to the /bin folder of the Java version you want to check, and type java -version there.

提交回复
热议问题