简体   繁体   中英

Executable LibGDX Jar File doesn't load assets

My LibGDX project runs in Eclipse but when I export it to an executable JAR file I get "Couldn't load file: play_button_inactive.png" and "File not found: play_button_inactive.png (Internal)".

I refreshed and cleaned the project. I deleted my assets link in the Desktop Project and re-loaded it in the Build Path but the same errors persisted.

I looked inside the jar file and Eclipse packaged in the assets separately into the Jar file so I put them all into a new "assets" folder manually but I got the same errors when I ran it. I used the command

java -jar fileName.jar

Here is my Build Path.

构建路径1

构建路径2

Thanks for any suggestions as to what I am doing wrong.

UPDATE : After reading around I found a solution which is to put all the assets into the same directory as the jar file. Is there any way to package them into the jar file?

I fixed the problem by not using Eclipse's jar file building tools and used gradlew desktop:dist instead.

This works perfectly and packages all resources and files into the generated jar file.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM