java获取操作系统或jre的信息

 

From System Properties you can find information about the operating system, the user, and the version of Java.

The property names (keys) and values are stored in a Properties structure. (See Properties). A Propertiesobject can also be used to store your own program properties in a file.

Getting the System Properties

Typically you get one property at a time by supplying the key in a call to System.getProperty().

  • String System.getProperty(String key) 
    Returns the value of property key as a String.
  • String System.getProperty(String key, String default) 
    Returns the value of property key as a string, or default if the property did not exist.
  • Properties System.getProperties() 
    Returns a Properties object which has the value of all the properties. There are several ways to work with this object; see below for one example.

Example

String userDir = System.getProperty("user.dir");

A list of system properties

Here are the properties that displayed on my system.

awt.toolkit=sun.awt.windows.WToolkit
file.encoding=Cp1252
file.encoding.pkg=sun.io
file.separator=/
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.awt.printerjob=sun.awt.windows.WPrinterJob
java.class.path=.;c:/classpath/com.fredswartz.utilities.jar;c:/classpath/TableLayout.jar;c:/classpath/swixml.jar;c:/classpath/jdom.jar;c:/classpath/pmd-1.8/lib/pmd-1.8.jar;C:/classpath/pmd-1.8/lib/jaxen-core-1.0-fcs.jar;C:/classpath/com.fredswartz.guiUtils.jar;C:/classpath/com.fredswartz.fmt-0.7.jar;C:/Program Files/IBM/Cloudscape_10.0/lib/derby.jar
java.class.version=49.0
java.endorsed.dirs=C:/Program Files/Java/jdk1.5.0_01/jre/lib/endorsed
java.ext.dirs=C:/Program Files/Java/jdk1.5.0_01/jre/lib/ext
java.home=C:/Program Files/Java/jdk1.5.0_01/jre
java.io.tmpdir=C:/DOCUME~1/Owner/LOCALS~1/Temp/
java.library.path=C:/Program Files/Java/jdk1.5.0_01/bin;.;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;c:/Python22;C:/Program Files/PC-Doctor for Windows/services;c:/ant/bin;c:/Program Files/Java/jdk/bin;c:/Program Files/Java/jdk/jre/javaws;C:/Program Files/Sybase/Adaptive Server Anywhere 6.0/win32;c:/classpath/jcsc/bin;c:/classpath/jcsc/bin;C:/Program Files/Microsoft Visual Studio/Common/Tools/WinNT;C:/Program Files/Microsoft Visual Studio/Common/MSDev98/Bin;C:/Program Files/Microsoft Visual Studio/Common/Tools;C:/Program Files/Microsoft Visual Studio/VC98/bin
java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition
java.runtime.version=1.5.0_01-b08
java.specification.name=Java Platform API Specification
java.specification.vendor=Sun Microsystems Inc.
java.specification.version=1.5
java.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi
java.version=1.5.0_01
java.vm.info=mixed mode, sharing
java.vm.name=Java HotSpot(TM) Client VM
java.vm.specification.name=Java Virtual Machine Specification
java.vm.specification.vendor=Sun Microsystems Inc.
java.vm.specification.version=1.0
java.vm.vendor=Sun Microsystems Inc.
java.vm.version=1.5.0_01-b08
line.separator=

os.arch=x86
os.name=Windows XP
os.version=5.1
path.separator=;
sun.arch.data.model=32
sun.boot.class.path=C:/Program Files/Java/jdk1.5.0_01/jre/lib/rt.jar;C:/Program Files/Java/jdk1.5.0_01/jre/lib/i18n.jar;C:/Program Files/Java/jdk1.5.0_01/jre/lib/sunrsasign.jar;C:/Program Files/Java/jdk1.5.0_01/jre/lib/jsse.jar;C:/Program Files/Java/jdk1.5.0_01/jre/lib/jce.jar;C:/Program Files/Java/jdk1.5.0_01/jre/lib/charsets.jar;C:/Program Files/Java/jdk1.5.0_01/jre/classes
sun.boot.library.path=C:/Program Files/Java/jdk1.5.0_01/jre/bin
sun.cpu.endian=little
sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86
sun.desktop=windows
sun.io.unicode.encoding=UnicodeLittle
sun.jnu.encoding=Cp1252
sun.management.compiler=HotSpot Client Compiler
sun.os.patch.level=Service Pack 2
user.country=US
user.dir=C:/0www-workingnotes/notes-java-working/io/30properties_and_preferences/40sysprops/SysPropList
user.home=C:/Documents and Settings/Owner
user.language=en
user.name=Owner
user.timezone=
user.variant=

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值