简体   繁体   中英

Deploying a JApplet: ClassNotFoundException

Edit 2: I created a html in the root directory and placed the jar file in the same place, I could then get the applet to run (though I had some issues with self-signed security). This tells me the problem is in the applet code. Any ideas why it wouldn't find the class when if I can remove the codebase attribute it runs correctly?

Edit 1: I have updated the entry point to remove the frame. I also tested with the HelloWorld applet and still received the same error.


I'm fairly new to Java so I'll try to explain my problem as clearly as I can and with plenty of detail. If I miss anything please let me know. I'm also aware that this problem is frequently asked about on here, I've done a fair bit of research and found conflicting responses and nothing that worked.

I have developed a JApplet in eclipse, exported a jar file for the project and am attempting to deploy it on my website. However, when I attempt to view the applet online I get the error: ClassNotFoundException. It is probably also worth mentioning that I am trying to deploy this JApplet through wordpress.

Here is the html code I'm using to deploy:

<applet code = 'gui.ConverterGUI.class' 
    codebase = 'http://www.myurl.co.uk/Java/'
    archive = 'AConverter.jar'
    width = 800
    height = 600>
    <param name="permissions" value="all-permissions" />
</applet>

My applet has a few packages and classes which I think I have set up and exported correctly, but incase that is causing problems, here is my main entry point:

public class ConverterGUI extends JApplet {
// Current program ver.
public static final double VERSION = 0.0;


public void init() {
    // Make it look nicer.
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch(Exception e) {
        e.printStackTrace();
    }



    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            createAndShowGUI();
        }
    });
}


    private void createAndShowGUI() {
        System.out.println("Created GUI on EDT? "+
                SwingUtilities.isEventDispatchThread());

        //JFrame f = new JFrame("Converter GUI");
        ResultDisplay resultDisplay = new ResultDisplay();
        getContentPane().add(resultDisplay, BorderLayout.CENTER);
        getContentPane().add(new InputFields(resultDisplay), BorderLayout.NORTH);
    }
}

我的项目套件设定

This is my project layout.

I've exported the jar using Eclipse, I've got the impression that this means it has been signed properly already, but if this is not the case and it is causing issues, I'd appreciate being pointed in the right direction to do this (I do have eclipse set up with the JDK rather than JRE).

The issue was in the html code and the way wordpress was interpreting it. For future reference, I fixed the issue by removing the lines from the html code and using double quotes, as follows:

<applet code = "gui.ConverterGUI.class" codebase="http://www.myurl.co.uk/Java/" archive="AConverter.jar" width=800 height=600><param name="permissions" value="all-permissions" /></applet>

Nonetheless I did get some useful advice here. Thanks all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM