Java Basic series: System.getenv ()

Source: Internet
Author: User

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 ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.