小弟最近忙着做个手机游戏,由于刚接触,所以,遇到一些问题,自己无法解决还请大家多帮忙!
我在编译时出现了下面的错误:
F:\ljh\WTK22\apps\KetrisGame\src\KetrisMap.java:39: cannot access
java.lang.NoClassDefFoundError file java\lang\
NoClassDefFoundError.class not found
KetrisMap.class.getResourceAsStream( "/chimes.wav ");
^
1 error
com.sun.kvem.ktools.ExecutionException
程序如下:
public static Player player;
static {
try {
InputStream is =
KetrisMap.class.getResourceAsStream( "/chimes.wav ");
player = Manager.createPlayer(is, "audio/x-wav ");
}
catch (
IOException ioe) {
ioe.printStackTrace();
}
catch (MediaException me) {
me.printStackTrace();
}
}
------解决方案--------------------不要用 .class
推荐改用统一的写法
InputStream is=Class.forName( "java.lang.Object ").getResourceAsStream( " ");
------解决方案--------------------凡是涉及流操作的时候:must be caught or declared to be thrown