简体   繁体   English

在eclipse中导出可执行文件/可运行jar

[英]Exporting executable/runnable jar in eclipse

I have a problem extracting my current project into an executable jar file. 我在将当前项目提取到可执行jar文件时遇到问题。 When I'm in eclipse and press the run button everything works fine, but when I do 当我在日食中按下运行按钮时,一切正常,但是当我这样做时

Export -> Runnable JAR File -> Choose right Project, Libary handling: Extract required libraries into generated JAR -> Finish 

and then start the .jar file; 然后启动.jar文件; the only thing I get is a window with a grey canvas. 我唯一得到的是带有灰色画布的窗口。 It should start the game I programmed (spaceInvaders). 它应该启动我编写的游戏(spaceInvaders)。

https://github.com/datosh/SpaceInvaders

Here is the link to the github where I uploaded the project. 这是我上载项目的github的链接。 I really don't know where the error is and where to look. 我真的不知道错误在哪里,在哪里看。 In my code? 在我的代码中? In my installed JRE/JDK? 在我安装的JRE / JDK中? Am I doing something wrong while creating the jar? 创建罐子时我做错什么了吗?

Please help -.- 请帮忙 -。-

When your app is packages as a JAR, there are no files other than the JAR itself. 当您的应用程序打包为JAR时,除了JAR本身之外没有其他文件。 The File class is only for accessing resources on the local file system, but, as Jon Skeet said, you need to read from the application's classpath when it's been packaged into a JAR. File类仅用于访问本地文件系统上的资源,但是,正如Jon Skeet所说,当将应用程序打包到JAR中时,需要从应用程序的类路径中读取。 See https://stackoverflow.com/a/3376393/639520 参见https://stackoverflow.com/a/3376393/639520

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

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