2012-07-11 99 views
1

我想執行這個程序, http://java.sun.com/developer/technicalArticles/ThirdParty/WebCrawler/WebCrawler.java 程序編譯沒有任何錯誤我提到這個頁面後, http://www.velocityreviews.com/forums/t146972-web-crawler.htmlJava安全訪問控制異常

但是在使用該命令而執行「小程序查看WebCrawler.html」我得到這個例外..

Exception in thread "Thread-4" 
java.security.AccessControlException:access denied(java.net.SocketPermission java.sun.com:80 connect,resolve) 

at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323) 

at java.security.AccessController.checkPermission(AccessController.java:546) 

at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) 

at java.lang.SecurityManager.checkConnect(SecurityManager.java:1034) 

at sun.net.www.http.HttpClient.openServer(HttpClient.java:527) 

at sun.net.www.http.HttpClient.<init>(HttpClient.java:233) 

at sun.net.www.http.HttpClient.New(HttpClient.java:306) 

at sun.net.www.http.HttpClient.New(HttpClient.java:323) 

at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:860) 

at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:801) 

at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:726) 

at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049) 

at java.net.URL.openStream(URL.java:1010) 

at WebCrawler.robotSafe(WebCrawler.java:139) 

at WebCrawler.run(WebCrawler.java:235) 

at java.lang.Thread.run(Thread.java:619) 

我如何使它工作。

+0

你有訪問本地文件WebCrawler.html的權限? – supertopi 2012-07-11 18:26:35

+0

我如何設置權限? – rakesh 2012-07-12 06:23:34

回答

1

默認情況下,小應用程序只能連接到它所在的同一個服務器+端口。你可以做下列之一:

  1. 轉換應用程序到應用程序,removng安全限制
  2. 使用受信任/簽名的小

此外,你可以看看配置跨域對於小程序,請參見:

http://weblogs.java.net/blog/2008/05/28/java-doodle-crossdomainxml-support

+0

Reimus-我試圖將它轉換成一個簽名的小程序。但是,我很擔心在MANIFEST文件中分配啓動類。我應該添加哪個課程?必須添加此公共類WebCrawler擴展Applet實現的ActionListener,Runnable類或「public static void main(String argv [])」。 – rakesh 2012-07-14 06:14:19