Java provides us with the System.getproperty () function, which can obtain some parameters of the Java JVM and the operating system, which can be used for program judgment and so on.
The System.getproperty () method needs to pass a string argument, which indicates that the environment configuration needs to be obtained.
The parameters that can be passed are:
[Java]View Plaincopy print?
- <span style="font-size:18px" >system.getproperty ("java.vm.version"); Java Virtual machine version
- System.getproperty ("Java.vendor.url"); //java official website
- System.getproperty ("Java.vm.nam"); //java Virtual machine name
- System.getproperty ("User.country"); //Country or region
- System.getproperty ("User.dir"); //path of the project
- System.getproperty ("java.runtime.version"); Java Runtime Environment version
- System.getproperty ("Os.arch"); //Operating system bits (32 or up)
- System.getproperty ("Os.name"); //operating system name
- System.getproperty ("sun.jnu.encoding"); //encoding format
- System.getproperty ("os.version"); //Operating system version
- System.getproperty ("java.version"); //java version version </span>
In addition, you can pass a lot of parameters, not listed here, you can directly use
[Java]View Plaincopy print?
- System.getproperties (). List (System.out);
This code gets all the keys and values.
The role and use of System.getproperty () in Java