我在更新 Java 后开始出现问题(我认为)当我尝试连接到我的 Cpp 服务器(这似乎工作正常)时,我收到一条错误消息,我找不到任何帮助。
以下是错误消息
java.security.AccessControlException: access denied
("java.net.SocketPermission" "127.0.0.1:4000" "connect,resolve")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
at java.security.AccessController.checkPermission(AccessController.java:555)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1051)
at java.net.Socket.connect(Socket.java:574)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.<init>(Socket.java:425)
at java.net.Socket.<init>(Socket.java:208)
at jclientbare.init(jclientbare.java:27)
at sun.applet.AppletPanel.run(AppletPanel.java:434)
at java.lang.Thread.run(Thread.java:722)
Java源代码如下
import java.awt.*;
import java.applet.*;
import java.io.*;
import java.net.*;
import javax.swing.*;
public class jclientbare extends Applet {
static BufferedReader in;
static PrintStream out;
public void init() {
try {
System.out.println("Test NN");
Socket socket = new Socket( "localhost", 4000 );
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out = new PrintStream( socket.getOutputStream(), true);
}
catch (UnknownHostException e) {
JOptionPane.showMessageDialog(null, "Unknown Host..");
System.out.println("Unknown host: kq6py");
} catch (IOException e) {
JOptionPane.showMessageDialog(null, "NO IO.");
System.out.println("No I/O");
}
}
}
Java 小程序不注册连接,它只是用错误消息轰炸。任何帮助,将不胜感激!我认为这可能是 java.policy 的问题,但我不知道如何解决它。
呃,你如何进行堆栈跟踪?