从 Eclipse 导出的可运行 JAR 文件似乎无法执行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3669455/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Exported runnable JAR file from Eclipse doesn't seem to execute
提问by Chris Haines
(Disclaimer: I am not a Java programmer, and really have very little idea what I'm doing in Eclipse)
(免责声明:我不是 Java 程序员,并且真的不知道我在 Eclipse 中做什么)
I hacked out an application in Eclipse a while back which I finished off and exported as a JAR which runs nicely. I didn't take any notes or make any comments.
不久前,我在 Eclipse 中编写了一个应用程序,将其完成并导出为运行良好的 JAR。我没有做任何笔记或发表任何评论。
The time comes to make some changes to the project but I have to reload it all again because my PC has since been wiped so some settings etc have probably changed.
是时候对项目进行一些更改了,但我必须再次重新加载它,因为我的 PC 已被擦除,因此某些设置等可能已更改。
Anyway it all works and runs nicely from Eclipse. But when I export as a runnable JAR, and double click to run the application, it doesn't seem to execute.
无论如何,这一切都在 Eclipse 中运行良好。但是当我导出为一个可运行的JAR,双击运行该应用程序时,它似乎并没有执行。
I can see that there is an instance of javaw running, but no window appears. No errors. Nada.
我可以看到有一个 javaw 实例正在运行,但没有出现窗口。没有错误。纳达。
As I said, it works beautifully in Eclipse. Any ideas?
正如我所说,它在 Eclipse 中运行良好。有任何想法吗?
I have little idea of how I can detect what is going on - as I said, I am NOT a java programmer :-)
我对如何检测正在发生的事情一无所知 - 正如我所说,我不是 Java 程序员 :-)
回答by Stroboskop
Ok then, so you can mark the question closed:
好的,那么您可以将问题标记为关闭:
If your Java installation is registered for the .jar extension it will try to run the Jar (i guess that's what's happening). But it will do so quietly.
如果您的 Java 安装是为 .jar 扩展名注册的,它将尝试运行 Jar(我猜这就是正在发生的事情)。但它会悄悄地这样做。
In order to seewhat's happening (errors and such) you should try to run it from the command line with java -jar myfile.jar
.
为了查看发生了什么(错误等),您应该尝试从命令行使用java -jar myfile.jar
.