简体   繁体   中英

JAVA - Classloader can't find Applet main class

I won't put all source code because it's really huge but I will try to explain my problem the best I can do.

I have an applet com.dmp.applet.DMPApplet , It's the main applet class and this one should be the first to load

com.dmp.applet.DMPApplet :

package com.dmp.applet;
// Imports

public class DMPApplet extends Applet
{
    @Override
    public void init()
    {
        this.state = AppletState.OFF;
        this.running = true;

        CPSAPI.connector = (Cpsw32) Native.loadLibrary("cpsw32", Cpsw32.class);

    }

    @Override
    public void start()
    {
        CR_CPS cr = CR_CPS.fromShort(CPSAPI.connector.CPS_OuvertureSession(CPSAPI.pNomRessource, CPSAPI.pNomAppli, CPSAPI.pStatusService, CPSAPI.pNumSession.getReference(), CPSAPI.pFU.getReference()));
        System.out.println("OUVERTURE DE SESSION : " + cr.getMessage());

        this.jso = JSObject.getWindow(this);

        if(this.state == AppletState.OFF && this.running)
        {
            this.Attente_Connexion();
            this.Demande_Code_PIN();
        }

        if(this.state == AppletState.LOGGED && this.running)
        {
            this.Connexion_VS();
            this.Lancement_Gateway();
        }

        if(this.state == AppletState.READY && this.running)
        {
            this.Ecoute_Evenements_CPS();
            this.Fermeture();
        }
    }

    public void stop()
    {
        CR_CPS cr = CR_CPS.fromShort(CPSAPI.connector.CPS_FermetureSession(CPSAPI.pNumSession.getValue(), CPSAPI.pStatusService));
        System.out.println("FERMETURE DE SESSION : " + cr.getMessage());
    }

    public void destroy()
    {
        // TODO
    }

}

It's architecture is the basis for an applet to execute but when I test it under Eclipse (Juno) but every time I launch the project I get :

java.lang.ClassNotFoundException: com.dmp.applet.DMPApplet.class
    at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:211)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:144)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:662)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:785)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:714)
    at sun.applet.AppletPanel.run(AppletPanel.java:368)
    at java.lang.Thread.run(Thread.java:619)

Such a pain, I can't figure out what's happenning, the project works perfectly on another PC (the one my team mate use to develop), and it worked until two days ago...I have no clue...

The fact that there's a ".class" on the end here is suspicious:

java.lang.ClassNotFoundException: com.dmp.applet.DMPApplet.class

I'd expect this:

java.lang.ClassNotFoundException: com.dmp.applet.DMPApplet

How exactly are you launching it under Eclipse? (I've never written an applet in Eclipse.) If you have to specify the class anywhere, make sure you don't have the ".class" suffix, as it's not part of the class name.

Can you please make sure that your jdk is properly configured in your application build path on eclipse. Right click on your application on eclipse and goto build path. Select libraries and ensure the jdk is there.

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