我試圖導入我的ant腳本。它成功了。但是當我編譯它。我得到這個錯誤:在Netbeans 6.1中運行Ant腳本的問題
run-selected-file-in-src:
java.io.FileNotFoundException: ..\sounds\voice.wav (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at com.sun.media.sound.WaveFileReader.getAudioInputStream(WaveFileReader.java:205)
at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1162)
at SimpleSoundPlayer.<init>(SimpleSoundPlayer.java:35)
at SimpleSoundPlayer.main(SimpleSoundPlayer.java:12)
Exception in thread "main" java.lang.NullPointerException
at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:89)
at SimpleSoundPlayer.main(SimpleSoundPlayer.java:16)
D:\Windows\My Document\Latihan\Java\allsrc\ch04src\nbproject\ide-file-targets.xml:7: Java returned: 1
BUILD FAILED (total time: 0 seconds)
這是我的文件夾結構
root
+-build(all *.class store here)
+-images
+-nbproject(netbeans create it)
+-sounds(voice.wav where i want to load)
+-src(all *.java - When i compile. All *.class will store to "build" folder)
+-build.xml
我的問題是,爲什麼在類文件(SimpleSoundPlayer.class)沒有找到 「.. \聲音\ voice.wav」 。但是,當我嘗試從命令行「java SimpleSoundPlayer」它很好。
爲什麼會發生這種情況?
嗯... Thx爲您的重播。你有另一種解決方案來保持我的「聲音」文件夾在根?我的意思是不動它。這有可能嗎? – Kenjiro 2011-02-18 13:13:57