判斷jdk 是64位仍是32位

Sun has a Java System property to determine the bitness of the JVM: 32 or 64:html

sun.arch.data.model=32 // 32 bit JVM
sun.arch.data.model=64 // 64 bit JVM

You can usejava

System.getProperty("sun.arch.data.model")

to determine if its 32/64 from the program.oracle

From the sun.docs:ui

When writing Java code, how do I distinguish between 32 and 64-bit operation?spa

There's no public API that allows you to distinguish between 32 and 64-bit operation. Think of 64-bit as just another platform in the write once, run anywhere tradition. However, if you'd like to write code which is platform specific (shame on you), the system property sun.arch.data.model has the value "32", "64", or "unknown".code

The only good reason is if your java code is dependent upon native libraries and your code needs to determine which version (32 or 64bit) to load on startup.orm

相關文章
相關標籤/搜索