The system.getenv () method is to get the value of the specified environment variable.
The system.getenv () receive parameter is any string that returns the value of the environment variable when the specified environment variable is present, otherwise NULL is returned
System.getproperty () is to obtain the relevant properties of the system, including file encoding, operating system name, region, user name, etc., this property is generally obtained automatically by the JVM and cannot be set.
System.getproperty () receive parameters and their meanings are as follows:
| Parameter values |
Parameter meaning |
| Java.version |
Java Runtime Environment version |
| Java.vendor |
Java Runtime Environment Vendor |
| Java.vendor.url |
The URL of the Java vendor |
| Java.home |
Java installation directory |
| Java.vm.specification.version |
Java Virtual Machine Specification version |
| Java.vm.specification.vendor |
Java Virtual Machine Specification Provider |
| Java.vm.specification.name |
Java Virtual Machine Specification Name |
| Java.vm.version |
Java Virtual Machine Implementation version |
| Java.vm.vendor |
Java Virtual Machine Implementation Provider |
| Java.vm.name |
Java Virtual Machine Implementation name |
| Java.specification.version |
Java Runtime Environment Specification version |
| Java.specification.vendor |
Java Runtime Environment Specification vendor |
| Java.specification.name |
Java Runtime Environment Specification name |
| Java.class.version |
Java Class Format version number |
| Java.class.path |
Java class Path |
| Java.library.path |
List of paths to search when loading libraries |
| Java.io.tmpdir |
The default temporary file path |
| Java.compiler |
The name of the JIT compiler to use |
| Java.ext.dirs |
Path to one or more extended directories |
| Os.name |
Name of the operating system |
| Os.arch |
Architecture of the operating system |
| Os.version |
Version of the operating system |
| File.separator |
File delimiter ("/" in UNIX system) |
| Path.separator |
Path Delimiter (":" In UNIX system) |
| Line.separator |
Row delimiter ("/n" in UNIX system) |
| User.Name |
User's account name |
| User.home |
User's home directory |
| User.dir |
User's current working directory |
JAVA System.getproperty () and system.getenv () differences and examples