2012-09-21 49 views
0

我不會放置所有的源代碼,因爲它真的很大,但我會盡我所能解釋我的問題。JAVA - 類加載器找不到Applet主類

我有一個小程序com.dmp.applet.DMPApplet,這是主要的Applet類,這應該是第一個加載

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 
    } 

} 

它的架構是一個小程序來執行的基礎,但在我在Eclipse中(麥浚龍)測試,但我每次啓動這個項目時,我得到:

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) 

這樣的痛苦,我無法找出的發生寧,該項目完美地在另一臺PC上(我的隊友用來開發的)工作,它的工作,直到兩天前......我不知道...

+0

我的問題沒有了,如果我理解了我所遇到的問題,那就是Eclipse項目中的源文件和真正的源文件(來自svn)之間的同步。出於某種原因,重新啓動eclipse並不會刷新源文件... – SmasherHell

回答

0

事實上,有一個「.class」在這裏到底是可疑:

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

我期望這樣的:

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

到底是如何,你的Eclipse下開展嗎? (我從來沒有在Eclipse中寫過一個applet。)如果你不得不在任何地方指定類,確保你沒有「.class」後綴,因爲它不是類名的一部分。

+0

不,我不需要指定類,只需添加庫來構建路徑並右鍵單擊>運行方式...>在我的DMPApplet上運行「Java applet」 .java文件 – SmasherHell

-1

您可以確保您的jdk在eclipse上的應用程序構建路徑中正確配置。在eclipse上右鍵單擊你的應用程序並轉到構建路徑。選擇庫並確保jdk在那裏。

+0

JDK 1.6.0_21在我的庫中,我在再次編譯之前做了一個清理,同樣的異常... – SmasherHell