我有一个非常简单的测试程序,只打开一个JFrame,我想在浏览器中打开它。我知道我必须自己签名才能打开它,但它只会抛出这个错误:
java.lang.reflect.InvocationTargetException
我已经使用JARMAKER
签署了jar我的HTML加载jar:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
</head>
<body>
<p>Inhalt der Webseite</p>
<applet code=Simple_Frame.class
archive="Simple_Frame2.jar"
width="120" height="120">
</applet>
</body>
</html>
简单的测试程序:
import java.applet.Applet;
import java.awt.*;
/**
* Created by Flex on 22.10.14.
*/
public class Start extends Applet{
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
Simple_Frame ex = new Simple_Frame();
ex.setVisible(true);
}
});
}
}
import javax.swing.JFrame;
public class Simple_Frame extends JFrame {
public Simple_Frame() {
setTitle("Simple example");
setSize(300, 200);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
如何在我的localhost上的网页中打开一个Jar来测试它而没有出现这个错误,这个错误是什么意思?
答案 0 :(得分:1)
<applet code=Simple_Frame.class
archive="Simple_Frame2.jar"
width="120" height="120">
首先突然发现,Simple_Frame
不是applet。 Start
类就是这样。
<applet code=Start
archive="Simple_Frame2.jar"
width="120" height="120">
另一个提示是InvocationTargetException
通常是另一个更具体的例外的包装器。始终复制/粘贴完整的错误和异常输出!