【发布时间】:2013-10-16 03:02:33
【问题描述】:
我正在尝试以 html 代码打开我的 Applet.jar。
我的 Java 代码是:
public class NewJFrame extends javax.swing.JFrame {
public NewJFrame() {
initComponents();
}
private void initComponents() {
setTitle("Example");
//more lines code base in JFrame with button,labels etc
}
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}
}
我的html代码是:
<!DOCTYPE html>
<html>
<body>
<h1>Java Applet Example</h1>
<p><object type="application/x-java-applet" width="300" height="300"> <param name="code" value="NewJFrame.class" /> <param name="archive" value="20130717_Applet.jar" /> <param name="mayscript" value="true" /> Java failed to load </object></p>
</body>
</html>
因此,当我尝试使用浏览器打开 html 文件时,它会让我崩溃:
Java 错误:“ClassNotFoundException NewJFrame.class”
我将 Java 控制面板的安全性从“高”更改为“中”,但我得到了同样的错误。
【问题讨论】:
-
尝试更改为低。这里不是专家,但我想档案需要数字签名。我可能错了:)
-
没有“低”选项,最低为中
-
我看过这篇文章,这就是我将安全性从高更改为中的原因。,..但它不起作用!所以我用我的代码创建了一个新帖子,看看是否有人可以帮助我!
-
<applet>标签已过时尝试使用<object>标签。