Java 类“Controller”与同一包中其他类的信任级别不匹配
我已经创建了一个java traceroute小程序,它在eclipse appletviewer中运行良好,但当我在浏览器中执行它时,会出现以下错误: actionPerformed中出错:java.lang.SecurityException:类控制器与同一包中其他类的信任级别不匹配 我已经对jar文件进行了签名,并尝试对清单文件进行了很多更改,但仍然无法正常工作。我使用的是java jdk1.7.0_45 控制器类:Java 类“Controller”与同一包中其他类的信任级别不匹配,java,eclipse,applet,Java,Eclipse,Applet,我已经创建了一个java traceroute小程序,它在eclipse appletviewer中运行良好,但当我在浏览器中执行它时,会出现以下错误: actionPerformed中出错:java.lang.SecurityException:类控制器与同一包中其他类的信任级别不匹配 我已经对jar文件进行了签名,并尝试对清单文件进行了很多更改,但仍然无法正常工作。我使用的是java jdk1.7.0_45 控制器类: import java.io.BufferedReader; impor
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.util.ArrayList;
public class Controller {
public Controller(GUI gui) {
this.gui = gui;
}
private final String os = System.getProperty("os.name");
private GUI gui;
public void displayHopsOnConsole(final InputStream stream) {
gui.clearConsole();
Thread thread = new Thread() {
public void run() {
BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); //create BufferedReader to read the inputstream easily
ArrayList <String> hops = new ArrayList <String> ();
ArrayList <String> hopCoordinates = new ArrayList <String> ();
String hop;
String IP;
int i = 0;
try {
while ((hop = reader.readLine()) != null) { // while the input is not NULL, read every line separately
if (i >= 5 && hop.length() > 25) {
IP = getIpFromHop(hop); //Filter the hop and get the ip back
hops.add(IP); //put this ip in a arraylist
hopCoordinates.add(new Post(IP).getResponse());
}
gui.setConsoleOutput(hop);
System.out.println(hop);
i++;
}
reader.close(); //close buffer because finished
gui.setConsoleOutput("\n");
int c=2;
for(String str:hopCoordinates){
gui.setConsoleOutput(c + ": " + str);
c++;
}
}
catch (Exception ex) {
System.out.println("Error in displayHopsOnConsole" + ex);
}
}
};
thread.start(); //start thread
}
public void traceRoute(InetAddress address) {
try {
Process traceRt;
if (os.contains("Win") || os.contains("win")) {
traceRt = Runtime.getRuntime().exec("tracert " + address.getHostAddress());
}
else {
traceRt = Runtime.getRuntime().exec("traceroute " + address.getHostAddress());
}
displayHopsOnConsole(traceRt.getInputStream());
}
catch (Exception ex) {
System.out.println("error while performing trace route command, see traceRoute() " + ex);
}
}
public String getIpFromHop(String routeLine) {
String resultString = routeLine.substring(31, routeLine.length() - 1);
if (resultString.contains("[")) {
String[] splitString = resultString.split("\\[");
resultString = splitString[1].substring(0, splitString[1].length() - 1);
return resultString;
}
else {
if (!resultString.contains("-")) {
return resultString.replaceAll("\\s", "");
}
else {
return "Timeout!";
}
}
}
}
我的清单文件:
清单版本:1.0代码库:*权限:所有权限
应用程序库允许的代码库:*调用方允许的代码库:*
应用程序名称:GUI
可能是重复的我读过这个问题,但我找不到解决方案。请帮助我这是学校的一个项目,所以我必须在周一之前解决这个问题:
public void actionPerformed(ActionEvent e) {
if(e.getSource()==submitButton) {
try{
new Controller(this).traceRoute(InetAddress.getByName(targetField.getText())); //call traceRoute method to start traceroute on given target address
}
catch (Exception ex) {
System.out.println("error in actionPerformed(): " + ex);
}
}
}