Java System getProperties()方法

java.lang.System.getProperties() 方法确定当前系统属性。当前设置用于通过getProperty(String)方法使用系统属性返回一个Properties对象。

如果没有当前系统属性的集合,那么它首先创建并初始化系统属性的集合。这套系统属性包括以下键的值:

Key 描述
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 (" " on UNIX)
user.name User's account name
user.home User's home directory
user.dir User's current working directory

1 语法

public static Properties getProperties()

2 参数

3 返回值

此方法返回系统属性。

4 示例 

package com.yiidian;

/**
 * 一点教程网: http://www.yiidian.com
 */
/**
 * Java System getProperties()方法
 */
import java.lang.*;

public class SystemDemo {

   public static void main(String[] args) {

      // this will list the current system properties
      Properties p = System.getProperties();
      p.list(System.out);
  }
} 

输出结果为:

-- listing properties --
java.runtime.name=Java(TM) SE Runtime Environment
sun.boot.library.path=C:Program FilesJavajdk1.6.0_06jre...
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
user.country=US
sun.java.launcher=SUN_STANDARD
sun.os.patch.level=Service Pack 2
java.vm.specification.name=Java Virtual Machine Specification
user.dir=C:Program FilesJavajdk1.6.0_06in
java.runtime.version=1.6.0_06-b02
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs=C:Program FilesJavajdk1.6.0_06jre...
os.arch=x86
java.io.tmpdir=C:DOCUME~1AMIT~1.AMILOCALS~1Temp
line.separator=

java.vm.specification.vendor=Sun Microsystems Inc.
user.variant=
os.name=Windows XP
sun.jnu.encoding=Cp1252
java.library.path=C:Program FilesJavajdk1.6.0_06in...
java.specification.name=Java Platform API Specification
java.class.version=50.0
sun.management.compiler=HotSpot Client Compiler
os.version=5.1
user.home=C:Documents and Settingsamit.AMIT-4...
user.timezone=
java.awt.printerjob=sun.awt.windows.WPrinterJob
file.encoding=Cp1252
java.specification.version=1.6
user.name=amit
java.class.path=.
java.vm.specification.version=1.0
sun.arch.data.model=32
java.home=C:Program FilesJavajdk1.6.0_06jre
java.specification.vendor=Sun Microsystems Inc.
user.language=en
awt.toolkit=sun.awt.windows.WToolkit
java.vm.info=mixed mode, sharing
java.version=1.6.0_06
java.ext.dirs=C:Program FilesJavajdk1.6.0_06jre...
sun.boot.class.path=C:Program FilesJavajdk1.6.0_06jre...
java.vendor=Sun Microsystems Inc.
file.separator=
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport...
sun.cpu.endian=little
sun.io.unicode.encoding=UnicodeLittle
sun.desktop=windows
sun.cpu.isalist=

 

热门文章

优秀文章