欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Java获取系统参数 博客分类: java javajdksun 

程序员文章站 2024-03-18 18:11:40
...

最近由于要通过Java获取系统参数,苦于资料不全,就自己写了个方法来获取系统参数,代码如下:

import java.util.Enumeration;
import java.util.Properties;
/**
 * 
 * @author wufeji
 * email:wufeji#qq.com
 *
 */

public class SystemProperties {
	public static void main(String[] args) {
		Properties pros=System.getProperties();
		Enumeration<?> keys=pros.keys();
		while(keys.hasMoreElements()){
			String prokey=(String) keys.nextElement();
			String provalue=System.getProperty(prokey);
			System.out.printf("%-35s%-20s\n", prokey,provalue);
		}
	}
}

 执行结果如下:

java.runtime.name                  Java(TM) SE Runtime Environment
sun.boot.library.path              D:\Java\jdk1.6\jre\bin
java.vm.version                    20.12-b01           
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                           D:\Workspaces\MyEclipse 10\test
java.runtime.version               1.6.0_37-b06        
java.awt.graphicsenv               sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs                 D:\Java\jdk1.6\jre\lib\endorsed
os.arch                            x86                 
java.io.tmpdir                     C:\Users\ADMINI~1\AppData\Local\Temp\
line.separator                     
                  
java.vm.specification.vendor       Sun Microsystems Inc.
user.variant                                           
os.name                            Windows 7           
sun.jnu.encoding                   GBK                 
java.library.path                  D:\Java\jdk1.6\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:/Program Files/MyEclipse/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin/client;D:/Program Files/MyEclipse/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin;D:/Program Files/MyEclipse/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/i386;D:\Java\jdk1.6\bin;D:\Java\jdk1.6\jre\bin;C:\Program Files\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;D:\Program Files\Subversion\bin;D:\Program Files\TortoiseSVN\bin;C:\MinGW\bin;D:\Program Files\instantclient_10_2;D:\Java\ant\apache-ant-1.9.0\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\Administrator
user.timezone                                          
java.awt.printerjob                sun.awt.windows.WPrinterJob
file.encoding                      GBK                 
java.specification.version         1.6                 
java.class.path                    D:\Workspaces\MyEclipse 10\test\bin;E:\jar包\jna\jna-3.5.2.jar;E:\jar包\structs2\struts-2.3.8\lib\json-lib-2.3-jdk15.jar;E:\jar包\structs2\struts-2.3.8\lib\commons-beanutils-1.8.0.jar;E:\jar包\structs2\struts-2.3.8\lib\commons-collections-3.1.jar;E:\jar包\structs2\struts-2.3.8\lib\commons-lang-2.4.jar;E:\jar包\structs2\struts-2.3.8\lib\commons-logging-1.1.1.jar;E:\jar包\structs2\struts-2.3.8\lib\ezmorph-1.0.6.jar
user.name                          Administrator       
java.vm.specification.version      1.0                 
sun.java.command                   SystemProperties    
java.home                          D:\Java\jdk1.6\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_37            
java.ext.dirs                      D:\Java\jdk1.6\jre\lib\ext;C:\Windows\Sun\Java\lib\ext
sun.boot.class.path                D:\Java\jdk1.6\jre\lib\resources.jar;D:\Java\jdk1.6\jre\lib\rt.jar;D:\Java\jdk1.6\jre\lib\sunrsasign.jar;D:\Java\jdk1.6\jre\lib\jsse.jar;D:\Java\jdk1.6\jre\lib\jce.jar;D:\Java\jdk1.6\jre\lib\charsets.jar;D:\Java\jdk1.6\jre\lib\modules\jdk.boot.jar;D:\Java\jdk1.6\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                    pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86

 

 

相关标签: java jdk sun