简体   繁体   中英

I programmatically determine operating system in Java?

I learn the system features as follows:

System.getProperty("os.arch")

Output for 64 bit computer: amd64

but when I use a 32 bit java version on a 64 bit computer, the result is: x86

How can I learn the correct result even though I have java 32 bit java installed on a 64 bit computer?

Thank you

This topic is covered by the Java Tutorials from Oracle.

  • "os.arch" Operating system architecture
  • "os.name" Operating system name
  • "os.version" Operating system version

The values for os.arch are explained on Wikipedia.

  • x86 signifies the 32-bit architecture originally from Intel .
  • amd64 signifies the 64-bit extension of that architecture, invented by AMD , later adopted by Intel as well.

(By the way, other architectures exist, such as ARM .)

The first means Java is running on a 32-bit machine, or Java is running on a 64-bit machine in 32-bit compatibility mode.

The second means Java is running in 64-bit mode on a 64-bit machine.

How can I learn the correct result even though I have java 32 bit java installed on a 64 bit computer?

(A) I don't know. (B) Your Question is moot. The 32-bit version of the JVM running on a 64-bit machine has the constraints of a 32-bit machine. The JVM only sees what appears to be a 32-bit machine. From the perspective of Java, the fact that the host hardware and OS may be 64-bit is irrelevant.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM