我正在尝试执行此程序, http://java.sun.com/developer/technicalArticles/ThirdParty/WebCrawler/WebCrawler.java 在我推荐此页面后,程序编译没有任何错误, http://www.velocityreviews.com/forums/t146972-web-crawler.html
但是在使用“appletviewer 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 :(得分:1)
默认情况下,applet只能连接到它所在的同一服务器+端口。您可以执行以下操作之一:
您还可以查看为applet配置交叉域,请参阅:
http://weblogs.java.net/blog/2008/05/28/java-doodle-crossdomainxml-support
答案 1 :(得分:0)
自行签署applet(你可以免费做)非常简单。如果您不对applet进行签名,则只能获得最低限度的安全访问权限,并且不会授予对套接字的访问权限。
简单的3步指南就在这里:
http://www.narendranaidu.com/2007/11/3-easy-steps-to-self-sign-applet-jar.html
或更深入的探索: http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html