我正在尝试以 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”</p>
我将 java 控制面板的安全性从高更改为中,但我得到了同样的错误。