java中的system.getproperty(String key)信息

星期五, 2011-12-30 | Author: Lee | JAVA-and-J2EE | 4,650 views

经常可以在程序中看到别人用System.getProperty(“user.dir”);这种信息,其实这个并不什么都是系统自带的属性;

可以查看java API 里 System 这个类里 getProperties 方法下有这样的说明:
Description of Associated Value

java.version Java Runtime Environment version
java.vendor Java Runtime Environment vendor
java.vendor.url Java vendor URL
java.home Java installation directory
java.vm.specification.version Java Virtual Machine specification version
java.vm.specification.vendor Java Virtual Machine specification vendor
java.vm.specification.name Java Virtual Machine specification name
java.vm.version Java Virtual Machine implementation version
java.vm.vendor Java Virtual Machine implementation vendor
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 Default temp file path
java.compiler Name of JIT compiler to use
java.ext.dirs Path of extension directory or directories
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator ("/" on UNIX)
path.separator Path separator (":" on UNIX)
line.separator Line separator ("\n" on UNIX)
user.name User’s account name
user.home User’s home directory
user.dir User’s current working directory

Multiple paths in a system property value are separated by the path separator character of the platform.

你可以自己执行代码查看:会比api多一些的
package com.liyz.test;

import java.util.Properties;

public class TestPro {

/**
* @param args
*/
public static void main(String[] args) {
System.out.println(System.getProperty(“user.dir”));
Properties pro = System.getProperties();
for (Object o : pro.keySet()) {
System.out.print(o+” ===>”);
System.out.println(pro.get(o));
}
}
}

结果:
F:\workspace\test
java.runtime.name ===>Java(TM) SE Runtime Environment
sun.boot.library.path ===>C:\Program Files\Java\jdk1.6.0_06\jre\bin
java.vm.version ===>10.0-b22
java.vm.vendor ===>Sun Microsystems Inc.
java.vendor.url ===>http://java.sun.com/
path.separator ===>;
java.vm.name ===>Java HotSpot(TM) Client VM
file.encoding.pkg ===>sun.io
sun.java.launcher ===>SUN_STANDARD
user.country ===>CN
sun.os.patch.level ===>
java.vm.specification.name ===>Java Virtual Machine Specification
user.dir ===>F:\workspace\test
java.runtime.version ===>1.6.0_06-b02
java.awt.graphicsenv ===>sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs ===>C:\Program Files\Java\jdk1.6.0_06\jre\lib\endorsed
os.arch ===>x86
java.io.tmpdir ===>C:\Users\no\AppData\Local\Temp\
line.separator ===>

java.vm.specification.vendor ===>Sun Microsystems Inc.
user.variant ===>
os.name ===>Windows Vista
sun.jnu.encoding ===>GBK
java.library.path ===>C:\Program Files\Java\jdk1.6.0_06\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jdk1.6.0_06/bin/../jre/bin/client;C:/Program Files/Java/jdk1.6.0_06/bin/../jre/bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Users\no\Desktop\dex2jar-0.0.7.8-SNAPSHOT\dex2jar-0.0.7.8-SNAPSHOT;C:\Program Files\Java\jdk1.6.0_06\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;F:\soft\MySQLTools\MySqlServer\bin;F:\SecureCRT\Client\;C:\Program Files\Windows Live\Shared;C:\Program Files\Common Files\Thunder Network\KanKan\Codecs;C:\Program Files\QuickTime\QTSystem\;D:\tools\apache-maven-3.0.3\bin;C:\Program Files\Java\jdk1.6.0_06\bin;C:\Program Files\proXPN\bin;E:\maven\apache-maven-3.0.3\bin
java.specification.name ===>Java Platform API Specification
java.class.version ===>50.0
sun.management.compiler ===>HotSpot Client Compiler
os.version ===>6.1
user.home ===>C:\Users\no
user.timezone ===>
java.awt.printerjob ===>sun.awt.windows.WPrinterJob
file.encoding ===>UTF-8
java.specification.version ===>1.6
java.class.path ===>F:\workspace\test\bin;F:\mvnLib\dom4j-2.0.0-ALPHA-2.jar;F:\libxdjplug\commons-beanutils-1.6.jar;F:\libxdjplug\commons-collections.jar;F:\libxdjplug\commons-logging-1.0.4.jar;F:\libxdjplug\commons-logging-api-1.1.jar;F:\poolsLib\htmlparser-1.5.jar;F:\poolsLib\commons-digester-1.8.jar;F:\poolsLib\commons.codec-1.3.0.jar;F:\libxdjplug\commons-lang-2.4.jar;F:\libxdjplug\jxcell.jar;F:\libxdjplug\mysql-connector-java-5.1.10-bin.jar
user.name ===>no
java.vm.specification.version ===>1.0
java.home ===>C:\Program Files\Java\jdk1.6.0_06\jre
sun.arch.data.model ===>32
user.language ===>zh
java.specification.vendor ===>Sun Microsystems Inc.
awt.toolkit ===>sun.awt.windows.WToolkit
java.vm.info ===>mixed mode, sharing
java.version ===>1.6.0_06
java.ext.dirs ===>C:\Program Files\Java\jdk1.6.0_06\jre\lib\ext;C:\Windows\Sun\Java\lib\ext
sun.boot.class.path ===>C:\Program Files\Java\jdk1.6.0_06\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_06\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_06\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_06\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_06\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_06\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_06\jre\classes
java.vendor ===>Sun Microsystems Inc.
file.separator ===>\
java.vendor.url.bug ===>http://java.sun.com/cgi-bin/bugreport.cgi
sun.io.unicode.encoding ===>UnicodeLittle
sun.cpu.endian ===>little
sun.desktop ===>windows
sun.cpu.isalist ===>

Tags: , ,

文章作者: Lee

本文地址: https://www.pomelolee.com/860.html

除非注明,Pomelo Lee文章均为原创,转载请以链接形式标明本文地址

No comments yet.

Leave a comment

Search

文章分类

Links

Meta