简体   繁体   English

可执行的LibGDX Jar文件不会加载资产

[英]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)". 我的LibGDX项目在Eclipse中运行,但是当我将其导出到可执行JAR文件时,我得到“无法加载文件:play_button_inactive.png”和“找不到文件:play_button_inactive.png(内部)”。

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. 我查看了jar文件,然后将打包在资产中的Eclipse分别打包到Jar文件中,因此我将它们全部手动放入一个新的“ assets”文件夹中,但是运行它时遇到了相同的错误。 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. 更新 :阅读后,我找到了一个解决方案,该解决方案是将所有资产与jar文件放在同一目录中。 Is there any way to package them into the jar file? 有什么办法可以将它们打包到jar文件中?

I fixed the problem by not using Eclipse's jar file building tools and used gradlew desktop:dist instead. 我不使用Eclipse的jar文件构建工具,而是使用gradlew desktop:dist来解决此问题。

This works perfectly and packages all resources and files into the generated jar file. 这可以完美工作并将所有资源和文件打包到生成的jar文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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