0

它在 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)

我们有一个小程序,它将打开一个套接字连接与服务器套接字应用程序进行通信这里是用于打开套接字通信的小程序代码

Socket sock = new Socket();
InputStream is;
OutputStream os;
try {
    sock.connect(serverAddr, timeoutMs);
} catch(SocketTimeoutException ex) {
    return false;
}
is = sock.getInputStream();
os = sock.getOutputStream();

我们正在使用签名的小程序。任何帮助将不胜感激...

4

1 回答 1

0

顶部有一条线索, Exception in thread "cth" java.security.AccessControlException: access denied。您发布的代码片段很好,但我们需要更详细地查看它以找出拒绝访问的原因。

于 2014-10-22T13:33:46.410 回答