Get OS-level system information

后端 未结 16 1792
情话喂你
情话喂你 2020-11-22 02:02

I\'m currently building a Java app that could end up being run on many different platforms, but primarily variants of Solaris, Linux and Windows.

Has anyone been abl

16条回答
  •  忘了有多久
    2020-11-22 02:36

    You can get some system-level information by using System.getenv(), passing the relevant environment variable name as a parameter. For example, on Windows:

    System.getenv("PROCESSOR_IDENTIFIER")
    System.getenv("PROCESSOR_ARCHITECTURE")
    System.getenv("PROCESSOR_ARCHITEW6432")
    System.getenv("NUMBER_OF_PROCESSORS")
    

    For other operating systems the presence/absence and names of the relevant environment variables will differ.

提交回复
热议问题