执行 java -version 命令,如下图所示如果没有明确显示位数的,则说明是32位
C:\MyTools\jdk1.7.0\bin>java -version
java version "1.7."
Java(TM) SE Runtime Environment (build 1.7.-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode) C:\MyTools\jdk1.7.0\bin>
进一步验证可通过如下命令,输出结果显示不支持64位,则说明是32位
C:\MyTools\jdk1.7.0\bin>java -d32 -version
java version "1.7."
Java(TM) SE Runtime Environment (build 1.7.-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode) C:\MyTools\jdk1.7.0\bin>java -d64 -version
Error: This Java instance does not support a -bit JVM.
Please install the desired version. C:\MyTools\jdk1.7.0\bin>
对于64位的,命令执行结果如下
C:\MyTools\jdk1.8.0\bin>java -version
java version "1.8._"
Java(TM) SE Runtime Environment (build 1.8._-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode) C:\MyTools\jdk1.8.0\bin>java -d32 -version
Error: This Java instance does not support a -bit JVM.
Please install the desired version. C:\MyTools\jdk1.8.0\bin>java -d64 -version
java version "1.8._"
Java(TM) SE Runtime Environment (build 1.8._-b14)
Java HotSpot(TM) -Bit Server VM (build 25.102-b14, mixed mode) C:\MyTools\jdk1.8.0\bin>