当我尝试使用ImageIO时,为什么Java会挂在我的Mac上?

时间:2015-03-17 12:58:25

标签: java macos javax.imageio hang headless

昨天突然间,我的Java(实际上是Groovy)在尝试调用ImageIO.read(文件)时开始挂起ClassLoader.load(String,boolean)。堆栈跟踪表明它正在尝试加载与AWT相关的代码。

如果它是IntelliJ或Gradle问题,我尝试了命令行,它仍然挂起,但如果我指定了-Djava.awt.headless = true,显然与-XstartOnFirstThread SWT 2013相关,则成功运行了该点错误,但当然这意味着我无法从程序中显示窗口。

这甚至可以通过一个微不足道的“仅加载图像”程序获得。

相反,现有的基于Java的应用程序运行愉快,同一台机器上的全新用户没有问题。

移动我的所有帐户。与全新用户相比,文件和注销/检查环境变量以及检查我的环境变量是否有效。

1 个答案:

答案 0 :(得分:0)

我不确切地知道为什么会发生这种情况,但它直接与之前遭遇本机崩溃有关:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000131099b1b, pid=11165, tid=4867
#
# JRE version: Java(TM) SE Runtime Environment (8.0_31-b13) (build 1.8.0_31-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.31-b07 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [libtesseract.dylib+0x156b1b]  ELIST::length() const+0x5
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/tim/git/t4jhack/hs_err_pid11165.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

因为我刚刚再次触发它,问题立即重新开始。

应用程序崩溃说

AppMain quit unexpectedly.
Click reopen to open the application again.
This report will be sent to Apple automatically
[show details] [OK] [Reopen]

我点击了确定'并且'重新打开'各种各样 - 都会导致问题。

'修复'我偶然发现了:

在“系统偏好设置”中,打开Java控制面板,它将显示:

The last time you opened Java, it unexpectedly quit while reopening windows.
Do you want to try to reopen its windows again?
If you choose not to reopen windows, you may have to open and
position the windows yourself.
[don't reopen] [reopen]

您想要重新打开',然后只需确定生成的窗口。