我嘗試在Applet上加載圖像或聲音時出現問題。我使用LWJGL applet和Slick2d加載圖像/聲音。 但是,當我啓動與Netbeans的小程序,有沒有問題...... 還有就是我用來加載聲音的代碼:使用LWJGL/Slick2d小程序加載圖像/聲音
public class Files {
public static Audio sound;
public static void load() {
try {
sound = AudioLoader.getAudio("WAV", ResourceLoader.getResourceAsStream("/snd/Tir1-16b.wav"));
} catch (IOException ex) {
Logger.getLogger(Files.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("loaded with success !");
}
}
而且還有HTML頁面:
<applet code="org.lwjgl.util.applet.AppletLoader" archive="lwjgl_util_applet.jar" codebase="." width="800" height="600">
<!-- The following tags are mandatory -->
<!-- Name of Applet, will be used as name of directory it is saved in, and will uniquely identify it in cache -->
<param name="al_title" value="appletloadertest">
<!-- Main Applet Class -->
<param name="al_main" value="myapps.MyApps">
<!-- List of Jars to add to classpath -->
<param name="al_jars" value="lwjgl_applet.jar, lwjgl.jar, jinput.jar, lwjgl_util.jar MyApps.jar">
<!-- signed windows natives jar in a jar -->
<param name="al_windows" value="windows_natives.jar">
<!-- signed linux natives jar in a jar -->
<param name="al_linux" value="linux_natives.jar">
<!-- signed mac osx natives jar in a jar -->
<param name="al_mac" value="macosx_natives.jar">
<!-- signed solaris natives jar in a jar -->
<param name="al_solaris" value="solaris_natives.jar">
<!-- Tags under here are optional -->
<!-- whether to use cache - defaults to true -->
<!-- <param name="al_cache" value="true"> -->
<!-- Version of Applet (case insensitive String), applet files not redownloaded if same version already in cache -->
<!-- <param name="al_version" value="0.1"> -->
<!-- Specify the minimum JRE version required by your applet, defaults to "1.5" -->
<!-- <param name="al_min_jre" value="1.6"> -->
<!-- background color to paint with, defaults to white -->
<!-- <param name="boxbgcolor" value="#000000"> -->
<!-- foreground color to paint with, defaults to black -->
<!-- <param name="boxfgcolor" value="#ffffff"> -->
<!-- logo to paint while loading, will be centered, defaults to "appletlogo.gif" -->
<!-- <param name="al_logo" value="appletlogo.gif"> -->
<!-- progressbar to paint while loading. Will be painted on top of logo, width clipped to percentage done, defaults to "appletprogress.gif" -->
<!-- <param name="al_progressbar" value="appletprogress.gif"> -->
<!-- whether to run in debug mode -->
<!-- <param name="al_debug" value="true"> -->
<!-- whether to prepend host to cache path - defaults to true -->
<!-- <param name="al_prepend_host" value="true"> -->
<param name="separate_jvm" value="true">
</applet>
還有就是控制檯日誌顯示,當我啓動的HTML頁面的小程序:
null
java.lang.reflect.InvocationTargetException
at java.awt.EventQueue.invokeAndWait(Unknown Source)
at java.awt.EventQueue.invokeAndWait(Unknown Source)
at org.lwjgl.util.applet.AppletLoader.run(AppletLoader.java:906)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org/newdawn/slick/util/ResourceLoader
at myapps.Files.load(Files.java:24)
at myapps.MyApps.init(MyApps.java:32)
at org.lwjgl.util.applet.AppletLoader.switchApplet(AppletLoader.java:1330)
at org.lwjgl.util.applet.AppletLoader$2.run(AppletLoader.java:909)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(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: org.newdawn.slick.util.ResourceLoader
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 18 more
空肯定意味着可變音頻爲空。這也意味着該文件可能沒有找到...所以我試圖把目錄「snd」和「sprites」放在applet目錄中,並且也放在我的applet的.jar上,但沒有任何反應......
任何人都可以幫我嗎?我搜索了很多時間嘗試在許多論壇上也發現這種問題,但沒有人幫助我...
非常感謝!
'NoClassDefFoundError'首先修復。什麼Jar是'ResourceLoader'位於? –