我想在html代碼中打開我的Applet.jar。加載一個JFrame到html
我的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 co的安全性控制面板從中等到高,但我得到相同的錯誤。
嘗試更改爲低。這裏不是專家,但我想檔案需要數字簽名。我可能是錯的:) –
沒有「低」選項最低爲中 – NickName
http://stackoverflow.com/questions/16196425/java-error-your-security-settings-have-blocked-a-local-application -from-runnin –