Java 應用程式預設許可權(簡例)

來源:互聯網
上載者:User

應用程式與Applet不同,沒有自動安裝的安全管理器。預設情況下,應用程式具備完全的許可權。這裡建立一個應用程式獲得系統屬性值 

/*
 * @(#)GetSysprop.java 1.0 06/08/07
 * get the system properties
 * jiazhen 2006.08.07
 */

import java.security.*;

class getSysProp
{
 public static void main(String args[]){
  String s;
  try{
   //預設返回字串為not specified
   
   //獲得系統名稱
   s=System.getProperty("os.name","not specified");
   System.out.println("The name of your operating system is:"+s);
   //獲得Java虛擬機器版本號碼
   s=System.getProperty("java.version","not specified");
   System.out.println("Your user home directory is:"+s);
   //獲得使用者路徑
   s=System.getProperty("usr.home","not specified");
   System.out.println("Your user home directory is:"+s);
   //獲得java_home
   s=System.getProperty("java.home","not specified");
   System.out.println("Your JRE installation directory is:"+s);   
  }
  catch(Exception e){
   e.printStackTrace();
  }
 }
}

java 策略檔案並沒有對所有的系統屬性授權,當程式讀取沒有被授權的系統屬性時,便會拋出異常。要獲得某些系統屬性的存取權限,可以自己建立策略檔案。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.