2011-01-14 88 views
0

我想運行我的Web應用程序的小程序,但我得到了一些錯誤,我下面提到的,請幫我走出這個問題錯誤而loadin小應用程序的Web應用程序

Java Plug-in 1.7.0 
Using JRE version 1.7.0-ea-b116 Java HotSpot(TM) Client VM 
User home directory = C:\Users\HONEY 
---------------------------------------------------- 
c: clear console window 
f: finalize objects on finalization queue 
g: garbage collect 
h: display this help message 
l: dump classloader list 
m: print memory usage 
o: trigger logging 
q: hide console 
r: reload policy configuration 
s: dump system and deployment properties 
t: dump thread list 
v: dump thread stack 
x: clear classloader cache 
0-5: set trace level to <n> 
---------------------------------------------------- 


java.lang.RuntimeException: java.lang.NoClassDefFoundError: mp3$1 
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) 
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) 
at java.lang.Thread.run(Unknown Source) 
Caused by: java.lang.NoClassDefFoundError: mp3$1 
at mp3.<init>(mp3.java:93) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
at java.lang.reflect.Constructor.newInstance(Unknown Source) 
at java.lang.Class.newInstance0(Unknown Source) 
at java.lang.Class.newInstance(Unknown Source) 
at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source) 
at java.awt.event.InvocationEvent.dispatch(Unknown Source) 
at java.awt.EventQueue.dispatchEvent(Unknown Source) 
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
at java.awt.EventDispatchThread.run(Unknown Source) 
Caused by: java.lang.ClassNotFoundException: mp3$1 
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) 
at java.lang.ClassLoader.loadClass(Unknown Source) 
... 16 more 
Caused by: java.io.IOException: open HTTP connection failed:http://viscous10.webng.com/mp3/mp3$1.class 
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source) 
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source) 
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
... 21 more 
Exception: java.lang.RuntimeException: java.lang.NoClassDefFoundError: mp3$1 

,但它只會發生,如果我運行事件 和簡單的小程序我從來沒有發生

+2

爲什麼要使用Java7的早期試用版具有相同的名稱?只要使用Java6,它就更有可能工作。 – skaffman 2011-01-14 20:58:21

+0

看起來,運行時相關庫不在類路徑或applet(jnlp)lib標記中列出。簡單的applet在運行時不會使用庫(mp3相關的?)。 – tompal18 2013-07-29 01:27:19

回答

0

這個錯誤意味着Java運行時無法找到您的mp3類的匿名內部類的.class文件。匿名內部類被命名爲OuterClass $ 1,OuterClass $ 2,OuterClass $ 3等等。匿名內部類的定義的例子:

button1.addActionListener(
    new java.awt.event.ActionListener() 
    { 
     public void actionPerformed(java.awt.event.ActionEvent e) 
     { 
      // do something 
     } 
    } 
); 

,因爲它似乎使用的是內部類,要知道,你的mp3.java源文件創建不同的.class文件,並確保所有的.class文件的可用於運行時環境(通過複製或將其添加到.jar文件等中)。

0

上運行Web瀏覽器的小程序

  1. 編寫Java代碼運行於Java
  2. 的應用程序通過使用命令提示符
  3. 給予適當的路徑使類文件,並在命令提示符運行Java文件創建類文件
  4. 將HTML文件添加小程序代碼,它<applet code=file.class archive =file.zip/jar></applet>
  5. 從控制面板啓用
  6. Java控制檯
  7. 運行HTML文件,並刷新窗口

注意:確保類文件,HTML文件,zip或jar文件,以避免任何混淆