System.getProperties()


System.out.println("-------------------------");
Properties p = System.getProperties();
for (Enumeration e = p.propertyNames(); e.hasMoreElements();) {
String key = (String) e.nextElement();
System.out.println(key + ":" + p.getProperty(key));
}
System.out.println("-------------------------");

[quote]
-------------------------
java.runtime.name:Java(TM) SE Runtime Environment
sun.boot.library.path:D:\Java\jdk1.6.0_03\jre\bin
java.vm.version:1.6.0_03-b05
shared.loader:
java.vm.vendor:Sun Microsystems Inc.
java.vendor.url:http://java.sun.com/
path.separator:;
java.vm.name:Java HotSpot(TM) Client VM
tomcat.util.buf.StringCache.byte.enabled:true
file.encoding.pkg:sun.io
java.util.logging.config.file:C:\Documents and Settings\liuwentao\.IntelliJIdea80\system\tomcat\Unnamed_newclass2009ccc9273f4\conf\logging.properties
user.country:CN
sun.java.launcher:SUN_STANDARD
sun.os.patch.level:Service Pack 3
java.vm.specification.name:Java Virtual Machine Specification
user.dir:D:\tomcat-8080\bin
java.runtime.version:1.6.0_03-b05
java.awt.graphicsenv:sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs:D:\tomcat-8080\endorsed
os.arch:x86
java.io.tmpdir:D:\tomcat-8080\temp
line.separator:

java.vm.specification.vendor:Sun Microsystems Inc.
user.variant:
java.util.logging.manager:org.apache.juli.ClassLoaderLogManager
java.naming.factory.url.pkgs:org.apache.naming
os.name:Windows XP
sun.jnu.encoding:GBK
java.library.path:D:\Java\jdk1.6.0_03\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;E:\oracle\product\10.2.0\db_1\bin;D:\Java\jdk1.6.0_03\bin;D:\apache-maven-2.1.0\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Thunder Network\KanKan\Codecs;D:\Program Files\Rational\common;C:\Program Files\Subversion\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\Program Files\StormII\Codec;C:\Program Files\StormII
java.specification.name:Java Platform API Specification
java.class.version:50.0
root:D:\project\koolearn\newclass2009\WebRoot\
sun.management.compiler:HotSpot Client Compiler
os.version:5.1
user.home:C:\Documents and Settings\liuwentao
user.timezone:Asia/Shanghai
catalina.useNaming:true
java.awt.printerjob:sun.awt.windows.WPrinterJob
appId:181
java.specification.version:1.6
file.encoding:GBK
catalina.home:D:\tomcat-8080
user.name:liuwentao
java.class.path:D:\Java\jdk1.6.0_03\lib\tools.jar;D:\tomcat-8080\bin\bootstrap.jar
java.naming.factory.initial:org.apache.naming.java.javaURLContextFactory
package.definition:sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.
java.vm.specification.version:1.0
sun.arch.data.model:32
java.home:D:\Java\jdk1.6.0_03\jre
java.specification.vendor:Sun Microsystems Inc.
user.language:zh
awt.toolkit:sun.awt.windows.WToolkit
java.vm.info:mixed mode
java.version:1.6.0_03
java.ext.dirs:D:\Java\jdk1.6.0_03\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
sun.boot.class.path:D:\Java\jdk1.6.0_03\jre\lib\resources.jar;D:\Java\jdk1.6.0_03\jre\lib\rt.jar;D:\Java\jdk1.6.0_03\jre\lib\sunrsasign.jar;D:\Java\jdk1.6.0_03\jre\lib\jsse.jar;D:\Java\jdk1.6.0_03\jre\lib\jce.jar;D:\Java\jdk1.6.0_03\jre\lib\charsets.jar;D:\Java\jdk1.6.0_03\jre\classes
java.vendor:Sun Microsystems Inc.
server.loader:
catalina.base:C:\Documents and Settings\liuwentao\.IntelliJIdea80\system\tomcat\Unnamed_newclass2009ccc9273f4
file.separator:\
java.vendor.url.bug:http://java.sun.com/cgi-bin/bugreport.cgi
common.loader:${catalina.home}/lib,${catalina.home}/lib/*.jar
sun.cpu.endian:little
sun.io.unicode.encoding:UnicodeLittle
package.access:sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans.
sun.desktop:windows
sun.cpu.isalist:pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86
-------------------------
[/quote]

如果上面遍历看着乱的话,再具体点:

[img]http://dl.iteye.com/upload/attachment/605533/32f3a16b-59cc-37c5-91fa-0e306b538235.png[/img]

/**
* User: liuwentao
* Time: 11-12-14 下午1:35
*/
public class properties {

public static void main(String[] args) {
Properties props = System.getProperties(); //系统属性
System.out.println("Java的运行环境版本:" + props.getProperty("java.version"));
System.out.println("Java的运行环境供应商:" + props.getProperty("java.vendor"));
System.out.println("Java供应商的URL:" + props.getProperty("java.vendor.url"));
System.out.println("Java的安装路径:" + props.getProperty("java.home"));
System.out.println("Java的虚拟机规范版本:" + props.getProperty("java.vm.specification.version"));
System.out.println("Java的虚拟机规范供应商:" + props.getProperty("java.vm.specification.vendor"));
System.out.println("Java的虚拟机规范名称:" + props.getProperty("java.vm.specification.name"));
System.out.println("Java的虚拟机实现版本:" + props.getProperty("java.vm.version"));
System.out.println("Java的虚拟机实现供应商:" + props.getProperty("java.vm.vendor"));
System.out.println("Java的虚拟机实现名称:" + props.getProperty("java.vm.name"));
System.out.println("Java运行时环境规范版本:" + props.getProperty("java.specification.version"));
System.out.println("Java运行时环境规范供应商:" + props.getProperty("java.specification.vender"));
System.out.println("Java运行时环境规范名称:" + props.getProperty("java.specification.name"));
System.out.println("Java的类格式版本号:" + props.getProperty("java.class.version"));
System.out.println("Java的类路径:" + props.getProperty("java.class.path"));
System.out.println("加载库时搜索的路径列表:" + props.getProperty("java.library.path"));
System.out.println("默认的临时文件路径:" + props.getProperty("java.io.tmpdir"));
System.out.println("一个或多个扩展目录的路径:" + props.getProperty("java.ext.dirs"));
System.out.println("操作系统的名称:" + props.getProperty("os.name"));
System.out.println("操作系统的构架:" + props.getProperty("os.arch"));
System.out.println("操作系统的版本:" + props.getProperty("os.version"));
System.out.println("文件分隔符:" + props.getProperty("file.separator")); //在 unix 系统中是"/"
System.out.println("路径分隔符:" + props.getProperty("path.separator")); //在 unix 系统中是":"
System.out.println("行分隔符:" + props.getProperty("line.separator")); //在 unix 系统中是"/n"
System.out.println("用户的账户名称:" + props.getProperty("user.name"));
System.out.println("用户的主目录:" + props.getProperty("user.home"));
System.out.println("用户的当前工作目录:" + props.getProperty("user.dir"));
}
}


[img]http://dl.iteye.com/upload/attachment/605535/cfb37f5a-6d9d-398f-8e1b-f589d3e020dc.png[/img]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值