Today turned to see Sytem.class source code, found Getenv () method, immediately before the light, so check the information to understand the following:
Method definition:
Public Static string getenv (string name) { = getSecurityManager (); if NULL { sm.checkpermission (new runtimepermission ("getenv.") +name)); } return processenvironment.getenv (name); }
The java.lang.System.getenv (String name) method gets the value of the specified environment variable. Environment variables are externally named values that depend on the system.
Environment variables should use a global role, or when an external system interface requires an environment variable (such as path).
The following example shows the use of the Java.lang.System.getenv () method:
Public Static voidMain (string[] args) {System.out.println ("Java Runtime Environment version:" +system.getproperty ("Java.version")); System.out.println ("Java Runtime Environment Vendor:" +system.getproperty ("Java.vendor")); System.out.println ("Java Vendor URL:" +system.getproperty ("Java.vendor.url"))); System.out.println ("Java installation directory:" +system.getproperty ("Java.home"))); System.out.println ("Java Virtual Machine Specification Version:" +system.getproperty ("Java.vm.specification.version"))); System.out.println ("Java class format version number:" +system.getproperty ("Java.class.version")); System.out.println ("Java classpath:" +system.getproperty ("Java.class.path"))); System.out.println ("Name of the operating system:" +system.getproperty ("Os.name")); System.out.println ("Architecture of the Operating system:" +system.getproperty ("Os.arch")); System.out.println ("Version of the operating system:" +system.getproperty ("Os.version")); System.out.println ("User's home directory:" +system.getproperty ("User.home"))); System.out.println ("User's current working directory:" +system.getproperty ("User.dir"))); System.out.println ("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); System.out.println ("Custom variable GetProperty conf_location:" +system.getproperty ("Conf.location")); System.out.println ("--------------------------------------------"); System.out.println ("Custom variable getenv conf_location:" +system.getenv ("Conf.location"));}}
Java Basic series: System.getenv ()