如果缺少jar,则使用"jpackage"创建的可执行文件会静默失败 [英] executable created with "jpackage"silently fails if jar is missing

查看:41
本文介绍了如果缺少jar,则使用"jpackage"创建的可执行文件会静默失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经使用jpackage打包了我们的应用程序,并且效果很好.

We have packaged our application with jpackage and it works nicely.

以某种方式无意中从安装目录中删除了主jar.从那以后,.exe"无法启动(很明显).问题是它没有显示任何类型的错误消息,因此我们花了一段时间才意识到出了什么问题.

Somehow someone inadvertently deleted the main jar from the installation directory. Since then the '.exe' failed to launch (obviously). Problem is it didn't show any kind of error message, so it took us a while to realize what was wrong.

是否可以通过某种方式让exe至少显示一些有用的错误消息?

Is there some way to have the exe show at least some useful error message?

推荐答案

如果使用 jpackage --win-console 参数激活控制台,则可以更容易地诊断jpackage生成的EXE问题.

Problems with the EXE generated by jpackage can be easier to diagnose if you activate the console with jpackage --win-console parameter.

您可能不想对主应用程序EXE执行此操作,因此可以使用第二个启动器来分发您的应用程序,该启动器启用了控制台并且具有相同的主类.只需创建一个新文件 appwithconsole.properties 并使用:

You might not want to do this for the main app EXE, so instead you could distribute your application with a second launcher which has the console enabled and same main-class. Just create a new file appwithconsole.properties and use:

jpackage --add-launcher debugversion=appwithconsole.properties ... rest of command line.

appwithconsole.properties

main-class=as.used.in.command.line
win-console=true

然后在删除jar后尝试 debugversion.exe ,它应该比没有控制台的EXE更清楚地报告错误:

Then try debugversion.exe after deleting the jar, it should report the error more clearly than the EXE without console:

Error: Could not find or load main class ...

这篇关于如果缺少jar,则使用"jpackage"创建的可执行文件会静默失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆