使用 javaw.exe 启动应用程序时不执行关闭挂钩 [英] The shutdown hook isn't executed when the application is launched using javaw.exe

查看:38
本文介绍了使用 javaw.exe 启动应用程序时不执行关闭挂钩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用 javaw.exe 来启动 Java 应用程序,则当用户从其 Windows 帐户注销时,不会执行关闭挂钩.该应用程序实际上是使用 launch4j 生成的 .exe 文件启动的,但我知道它使用 javaw.exe 来启动它.

If I'm using javaw.exe to launch a Java application, the shutdown hook isn't executed when users log off from their Windows account. The application is actually launched using a launch4j generated .exe file but I know it uses javaw.exe to start it.

这似乎是一个已知的错误:http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4302814

This seems to be a known bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4302814

有没有其他人遇到过这个问题?如果是这样,您是如何解决的?

Has anyone else had this problem? If so, how did you fix it?

谢谢!

推荐答案

该应用程序实际上是使用 launch4j 生成的 .exe 文件启动的,但我知道它使用 javaw.exe 来启动它.

The application is actually launched using a launch4j generated .exe file but I know it uses javaw.exe to start it.

我有一段时间没有使用 launch4j,但如果它直接这样做,我会感到相当惊讶.这些应用程序中的大多数都自己启动 jvm,而不是向 javaw 开炮.

I haven't used launch4j in a while, but I'd be fairly suprised if it directly did this. Most of these apps start the jvm themselves, rather than shelling out to javaw.

java.exe 和 javaw.exe 的唯一区别是 java.exe 自动附加了一个控制台.您引用的错误(以及它引用的其他错误)已关闭,因为 Sun 似乎对更好地处理 Windows 注销事件不感兴趣.据我所知,它只适用于 java.exe,因为控制台本身处理 WM_MESSAGES 的方式会减慢关机过程.

The only difference between java.exe and javaw.exe is that java.exe automatically attaches a console. The bug that you reference (and the others referenced by it) were closed as Sun doesn't appear to be interested in making the handling of Windows logoff events better. From what I can tell, it only works with java.exe, because the console itself handles the WM_MESSAGES in such a way that it slows down the shutdown process.

目前似乎唯一简单的解决方法是将 launch4j 配置中的headerType"更改为console".显然,这带来了一个丑陋的控制台.

It appears that the only easy workaround at the moment is to change the "headerType" in your launch4j config to "console". Obviously, this brings with it an ugly console.

我认为另一种选择是使用某种原生包装器,以更简洁的方式处理 Windows 消息.

I think the other alternative would be to use some sort of native wrapper of your on that handles windows messages in a cleaner way.

这篇关于使用 javaw.exe 启动应用程序时不执行关闭挂钩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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