【问题标题】:java does not exit back to prompt when running jar file fails运行jar文件失败时java不退出提示
【发布时间】:2011-05-19 10:34:59
【问题描述】:

在我的 RHEL 64 机器上运行 java -jar myfile.jar 时,如果由于某种原因安装失败,我不会返回提示 - 因此进程不会退出

在其他 RHEL 64 机器上,运行相同的 jar 文件时,如果失败,我会返回提示。

两台机器都运行相同版本的 java 1.6.0_25

有人知道什么会导致这种行为吗?

编辑:jar 有一个一开始就失败的 ant build xml(我添加了<fail/> 任务)。 运行文件时我得到了这个

Total time: 1 second
validate failed
org.tp23.antinstaller.InstallException: Error running the install, Ant run failed - examine the error logs for details
        at org.tp23.antinstaller.runtime.exe.AntLauncherFilter.exec(AntLauncherFilter.java:112)
        at org.tp23.antinstaller.runtime.exe.AntLauncherValidateFilter.exec(AntLauncherValidateFilter.java:53)
        at org.tp23.antinstaller.runtime.ExecInstall.exec(ExecInstall.java:89)
        at org.tp23.antinstaller.selfextract.SelfExtractor.main(SelfExtractor.java:372)
Install failed
Error running the install, Ant run failed - examine the error logs for details
Failed

但没有提示,进程仍在运行...

【问题讨论】:

  • 您确定安装失败了吗?你怎么知道的?您是否在某些文件上记录了一些错误?
  • MarcoS:我知道它失败了,因为我写了它,并且我明确告诉它不能尝试理解它为什么不退出。此外,在不同的机器上运行相同的文件确实会退出程序,因此它必须是与环境相关的问题

标签: linux jar java rhel


【解决方案1】:

可能是您仍然有一些非守护线程存在吗?尝试通过以下方式获取 Java 堆栈转储:

kill -QUIT <process_id>

【讨论】:

  • Simon: running java -jar myfile.jar 在新的 JVM 中运行文件对吗?那么为什么在一个环境中它会关闭线程而在我的环境中却没有呢?
  • Simon:运行你告诉我的会产生这个:pastebin.com/wt21r7ZZ。进程仍在运行
  • @michael:这很难回答,除非我们知道哪个线程导致代码继续运行。 jstack 做同样的事情,而且可能更容易使用,顺便说一句。
  • AWT 线程仍在运行,这意味着仍有一些 AWT 组件被引用和/或可见。
  • 好的,我已经确认了,我使用setenv DISPLAY 将屏幕输出重定向到我的电脑,以便 Xmanager 可以将它放在我的屏幕上。即使安装在静默模式下运行,我猜它仍在屏幕上使用。现在我已经禁用了setenv DISPLAY,它失败了,让我回到它应该的提示符。
猜你喜欢
  • 1970-01-01
  • 2012-01-01
  • 1970-01-01
  • 2014-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-02
  • 2017-05-10
相关资源
最近更新 更多