I created a desktop game in eclipse using Libgdx. The game runs great in eclipse, however the FileHandle list()
method doesn't work when exported to a jar file. I used the following lines of code:
songFiles = Gdx.files.internal("./bin/" + "songs/").list();
System.out.println(songFiles[0]);
Again, in eclipse it prints the file location.However when exported to a jar, I get a java.lang.ArrayIndexOutOfBoundsException: 0
error.
Cannot export default Java libGDX project as a jar from Eclipse looks similar to the issue that I am having
It says you created the list or array but u didn't initialize it with length. That's why you have 0 at the end of error message.
由于list()方法不能在桌面应用程序上使用,因此我将通过将歌曲目录中的文件名读写到文本文件来解决此问题。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.