Get environment variables in Java

Source: Internet
Author: User
Tags file separator
Environment variables are in the operating system and applications Program An important part of interaction. Getting or setting environment variables is a frequently used technology in programming. Here I reposted an article about how to get environment variables in Java. Article :
(Zz from http://www.javaidea.net/list.jsp? Topic = 3)

Set an environment variable debug to true at runtime: Java-ddebug = true yourclass
Set an environment variable debug to true in the program:System. setproperty ("debug", "true ");
Get an environment variable Debug:String DEBUG = system. getproperty ("debug ");

The following table lists some environment variables that have been defined by Java. getproperty ("key"). For more environment variables, see the JDK documentation.

Attribute name Description
Java. Version Java runtime version
Java. Home Java installation directory
Java. Class. Version Java version
Java. Class. Path Java class search path
Java. Io. tmpdir Default temporary directory
Java. Compiler Timely compiler used by Java
Java. Ext. dirs Java extension package directory
OS. Name Operating system name
OS. Arch Operating System Architecture
OS. Version Operating system version
File. Separator File separator ('/' in UNIX '/')
Path. Separator Path separator (':' in UNIX ':')
Line. Separator Line Break ('\ n' in UNIX ')
User. Name User Account Name
User. Home User directory
User. dir Current working directory of the user

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.