何为系统属性?
系统属性是指与用户程序相关的操作系统配置信息以及软件信息。
用户程序相关的属性例子
- file.separator:文件分隔符:Windows环境下为”\”,Linux环境下为”/”;
- user.dir:当前用户程序所在目录;
- path.separator:当前操作系统的路径分隔符;
- os.version:操作系统版本;
- user.name:用户登录名称;
- os.name:操作系统名称;
- java.ext.dirs:JDK的安装目录;
- java.home:Java实时运行环境的安装目录;
- user.home:用户主目录;
Java代码查看所有系统的属性
public class SystemProperty {
public static void main(String args[]) {
Properties props = System.getProperties();
Iterator<Object> iter = props.keySet().iterator();
while (iter.hasNext()) {
String key = (String) iter.next();
System.out.println(key + " = " + props.get(key));
}
}
}
我本机运行后的结果
java.runtime.name = Java(TM) SE Runtime Environment
sun.boot.library.path = F:\myeclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\bin
java.vm.version = 11.3-b02
java.vm.vendor = Sun Microsystems Inc.
java.vendor.url = http://java.sun.com/
path.separator = ;
java.vm.name = Java HotSpot(TM) 64-Bit Server VM
file.encoding.pkg = sun.io
sun.java.launcher = SUN_STANDARD
user.country = CN
sun.os.patch.level = Service Pack 1
java.vm.specification.name = Java Virtual Machine Specification
user.dir = E:\hxlprogrammerpath\javapractise
java.runtime.version = 1.6.0_13-b03
java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs = F:\myeclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\endorsed
os.arch = amd64
java.io.tmpdir = C:\Users\ADMINI~1\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 = F:\myeclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:\quick;C:\Oracle\Ora81\bin;D:\my-study-material\Maven\apache-maven-3.3.3\bin;E:\jdk\bin;F:\app\Administrator\product\11.2.0\dbhome_1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;E:\mysql-advanced-5.6.20-winx64\bin;C:\Program Files\TortoiseSVN\bin;E:\IBM_ROSE\common;E:\posix\mingw32\bin;F:\Vim\vim74
java.specification.name = Java Platform API Specification
java.class.version = 50.0
sun.management.compiler = HotSpot 64-Bit Server Compiler
os.version = 6.1
user.home = C:\Users\Administrator
user.timezone =
java.awt.printerjob = sun.awt.windows.WPrinterJob
file.encoding = GBK
java.specification.version = 1.6
java.class.path = E:\hxlprogrammerpath\javapractise\bin;F:\myeclipse\Common\plugins\org.junit_4.8.2.v4_8_2_v20110321-1705\junit.jar;F:\myeclipse\Common\plugins\org.hamcrest.core_1.1.0.v20090501071000.jar;E:\hxlprogrammerpath\javapractise\lib\poi-3.11-20141221.jar
user.name = Administrator
java.vm.specification.version = 1.0
java.home = F:\myeclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre
sun.arch.data.model = 64
user.language = zh
java.specification.vendor = Sun Microsystems Inc.
awt.toolkit = sun.awt.windows.WToolkit
java.vm.info = mixed mode
java.version = 1.6.0_13
java.ext.dirs = F:\myeclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\ext;C:\Windows\Sun\Java\lib\ext
sun.boot.class.path = F:\myeclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\resources.jar;F:\myeclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\rt.jar;F:\myeclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\sunrsasign.jar;F:\myeclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\jsse.jar;F:\myeclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\jce.jar;F:\myeclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\charsets.jar;F:\myeclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\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 = amd64
版权声明:本文为博主原创文章,未经博主允许不得转载。