我正在观看本教程,使用java制作游戏,而我正在将音乐导入游戏。但是,当我尝试使用此类中创建的方法加载声音时:
package main;
import java.util.HashMap;
import java.util.Map;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.Sound;
public class AudioPlayer {
public static Map<String, Sound> soundMap = new HashMap<String, Sound>();
public static Map<String, Music> musicMap = new HashMap<String, Music>();
public static void load(){
try {
soundMap.put("click_sound", new Sound("res/clickSound.ogg"));
musicMap.put("music", new Music("res/background_Music.ogg"));
} catch (SlickException e) {
e.printStackTrace();
}
}
public static Music getMusic(String key){
return musicMap.get(key);
}
public static Sound getSound(String key){
return soundMap.get(key);
}
}
我收到一条错误消息:
Exception in thread "main" java.lang.NoClassDefFoundError: com/jcraft/jorbis/Info
at org.newdawn.slick.openal.OggInputStream.<init>(OggInputStream.java:35)
at org.newdawn.slick.openal.OggDecoder.getData(OggDecoder.java:311)
at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:835)
at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:793)
at org.newdawn.slick.Sound.<init>(Sound.java:87)
at main.AudioPlayer.load(AudioPlayer.java:18)
at main.Game.<init>(Game.java:45)
at main.Game.main(Game.java:160)
Caused by: java.lang.ClassNotFoundException: com.jcraft.jorbis.Info
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 8 more
AL lib: (EE) alc_cleanup: 1 device not closed
我写错了什么?我导入了正确的外部罐子并完成了教程中说的所有内容。但是,我一直收到这个错误?