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 |