它在JDK 1.7或更早版本中运行良好,但是一旦我们使用JDK 8进行测试,我们就会遇到以下异常
Exception in thread "cth" java.security.AccessControlException: access denied ("java.net.SocketPermission" "IP:PORT" "connect,resolve")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at sun.plugin2.applet.SecurityManagerHelper.checkConnectHelper(Unknown Source)
at sun.plugin2.applet.AWTAppletSecurityManager.checkConnect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at iyp.simplegameapplet.d.f.a(Unknown Source)
at iyp.b.a.b$c.run(Unknown Source)
我们有一个applet,它将打开一个套接字连接以与服务器套接字应用程序通信,这里是用于打开套接字通信的applet代码
Socket sock = new Socket();
InputStream is;
OutputStream os;
try {
sock.connect(serverAddr, timeoutMs);
} catch(SocketTimeoutException ex) {
return false;
}
is = sock.getInputStream();
os = sock.getOutputStream();
我们正在使用已签名的小程序。 任何帮助将不胜感激......
答案 0 :(得分:0)
顶部有一条线索,线程“cth”中的异常java.security.AccessControlException:访问被拒绝。您发布的代码片段很好,但我们需要更详细地查看它,以找出拒绝访问的原因。