How do I programmatically determine operating system in Java?

后端 未结 19 2875
眼角桃花
眼角桃花 2020-11-22 04:56

I would like to determine the operating system of the host that my Java program is running programmatically (for example: I would like to be able to load different propertie

19条回答
  •  無奈伤痛
    2020-11-22 05:25

    If you're interested in how an open source project does stuff like this, you can check out the Terracotta class (Os.java) that handles this junk here:

    • http://svn.terracotta.org/svn/tc/dso/trunk/code/base/common/src/com/tc/util/runtime/
    • http://svn.terracotta.org/svn/tc/dso/tags/2.6.4/code/base/common/src/com/tc/util/runtime/

    And you can see a similar class to handle JVM versions (Vm.java and VmVersion.java) here:

    • http://svn.terracotta.org/svn/tc/dso/trunk/common/src/main/java/com/tc/util/runtime/

提交回复
热议问题