java獲取jdk、系統、服務器等信息

n42g 9年前發布 | 6K 次閱讀 Java

1、獲取jdk信息

System.out.println(System.getProperty("java.version"));     
        System.out.println(System.getProperty("java.vendor"));     
        System.out.println(System.getProperty("java.vendor.url"));     
        System.out.println(System.getProperty("java.home"));     
        System.out.println(System.getProperty("java.vm.specification.version"));     
        System.out.println(System.getProperty("java.vm.specification.vendor"));     
        System.out.println(System.getProperty("java.vm.specification.name"));     
        System.out.println(System.getProperty("java.vm.version"));     
        System.out.println(System.getProperty("java.vm.vendor"));     
        System.out.println(System.getProperty("java.vm.name"));     
        System.out.println(System.getProperty("java.specification.version"));     
        System.out.println(System.getProperty("java.specification.vendor"));     
        System.out.println(System.getProperty("java.specification.name"));     
        System.out.println(System.getProperty("java.class.version"));     
        System.out.println(System.getProperty("java.class.path"));     
        System.out.println(System.getProperty("java.library.path"));     
        System.out.println(System.getProperty("java.io.tmpdir"));     
        System.out.println(System.getProperty("java.compiler"));     
        System.out.println(System.getProperty("java.ext.dirs")); 

2、獲取系統信息

System.out.println(System.getProperty("os.name"));     
        System.out.println(System.getProperty("os.arch"));     
        System.out.println(System.getProperty("os.version"));     
        System.out.println(System.getProperty("file.separator"));     
        System.out.println(System.getProperty("path.separator"));     
        System.out.println(System.getProperty("line.separator"));     
        System.out.println(System.getProperty("user.name"));     
        System.out.println(System.getProperty("user.home"));                     
        System.out.println(System.getProperty("user.dir")); 

3.獲取Tomcat的版本 
<%= application.getServerInfo() %> 

 

=========

幾個常用Request.ServerVariables的中文 

本文件ip路徑:<%="http://&quot; & request.servervariables("server_name")&request.servervariables("script_name") %> 
本機ip:<%=request.servervariables("remote_addr")%> 
服務器名:<%=Request.ServerVariables("SERVER_NAME")%> 
服務器IP:<%=Request.ServerVariables("LOCAL_ADDR")%> 
服務器端口:<%=Request.ServerVariables("SERVER_PORT")%> 
服務器時間:<%=now%> 
IIS版本:<%=Request.ServerVariables("SERVER_SOFTWARE")%> 
腳本超時時間:<%=Server.ScriptTimeout%> 
本文件路徑:<%=server.mappath(Request.ServerVariables("SCRIPT_NAME"))%> 
服務器CPU數量:<%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%> 
服務器解譯引擎:<%=ScriptEngine & "/"& ScriptEngineMajorVersion&"."&ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion %> 
服務器操作系統:<%=Request.ServerVariables("OS")%> 
支持的文件類型:<%=Request.ServerVariables("HTTP_Accept")%> 
訪問的文件路徑:<%=Request.ServerVariables("HTTP_url")%> 
用戶代理的信息:<%=Request.ServerVariables("HTTP_USER_AGENT")%> 
獲取url中的文件名和傳過來的值:request.ServerVariables("script_name")+"?"+request.ServerVariableS("QUERY_STRING

 本文由用戶 n42g 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!