Java 基于 mac 的应用程序无法在旧版 MacOSX 中运行

Java based mac app is not working in old MacOSX

我开发了一个基于 Java 的应用程序并创建了一个桌面 mac 应用程序。如您所知,当您为 Mac 创建一个包时,您必须在包中嵌入完整的 JDK(在我的例子中是 1.8),因此目标是否具有 Java 已安装,您的应用程序随附。

在 MacOSX 10.10 和 10.9 中一切正常...(我没有在 10.7 或 10.8 中测试过)。

但是当我 运行 在 10.6.8 MacOSX Java 中崩溃时...在控制台中我看到了这个:

Process:         JavaAppLauncher [354]
Path:            /Applications/myapp.app/Contents/MacOS/JavaAppLauncher
Identifier:      com.myapp.desktop
Version:         1.0.8 (1)
Code Type:       X86-64 (Native)
Parent Process:  launchd [130]

Date/Time:       2015-02-27 16:58:14.384 +0100
OS Version:      Mac OS X 10.6.8 (10K549)
Report Version:  6

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000002, 0x0000000000000000
Crashed Thread:  3

Thread 0:  Dispatch queue: com.apple.main-thread
0   libSystem.B.dylib               0x00007fff8a4acd7a mach_msg_trap + 10
1   libSystem.B.dylib               0x00007fff8a4ad3ed mach_msg + 59
2   com.apple.CoreFoundation        0x00007fff848a2902 __CFRunLoopRun + 1698
3   com.apple.CoreFoundation        0x00007fff848a1d8f CFRunLoopRunSpecific + 575
4   libjli.dylib                    0x0000000100038b34 CreateExecutionEnvironment + 871
5   libjli.dylib                    0x0000000100034ac4 JLI_Launch + 1952
6   com.myapp.desktop          0x00000001d7448990 launch + 5696
7   com.myapp.desktop          0x00000001d7447136 main + 102
8   com.myapp.desktop          0x00000001d74470c4 start + 52

Thread 1:  Dispatch queue: com.apple.libdispatch-manager
0   libSystem.B.dylib               0x00007fff8a4c5c0a kevent + 10
1   libSystem.B.dylib               0x00007fff8a4c7add _dispatch_mgr_invoke + 154
2   libSystem.B.dylib               0x00007fff8a4c77b4 _dispatch_queue_invoke + 185
3   libSystem.B.dylib               0x00007fff8a4c72de _dispatch_worker_thread2 + 252
4   libSystem.B.dylib               0x00007fff8a4c6c08 _pthread_wqthread + 353
5   libSystem.B.dylib               0x00007fff8a4c6aa5 start_wqthread + 13

Thread 2:
0   libSystem.B.dylib               0x00007fff8a4e7a6a __semwait_signal + 10
1   libSystem.B.dylib               0x00007fff8a50e896 pthread_join + 844
2   libjli.dylib                    0x0000000100038134 ContinueInNewThread0 + 102
3   libjli.dylib                    0x0000000100035738 ContinueInNewThread + 201
4   libjli.dylib                    0x0000000100037f09 JVMInit + 315
5   libjli.dylib                    0x00000001000354b6 JLI_Launch + 4498
6   com.myapp.desktop          0x00000001d7448990 launch + 5696
7   com.myapp.desktop          0x00000001d7447136 main + 102
8   libjli.dylib                    0x00000001000387c6 apple_main + 92
9   libSystem.B.dylib               0x00007fff8a4e5fd6 _pthread_start + 331
10  libSystem.B.dylib               0x00007fff8a4e5e89 thread_start + 13

Thread 3 Crashed:
0   com.apple.CoreFoundation        0x00007fff848d98a1 ___forwarding___ + 673
1   com.apple.CoreFoundation        0x00007fff848d5a38 _CF_forwarding_prep_0 + 232
2   libobjc.A.dylib                 0x00007fff89347325 _class_initialize + 384
3   libobjc.A.dylib                 0x00007fff8935552b prepareForMethodLookup + 234
4   libobjc.A.dylib                 0x00007fff8934dcb9 lookUpMethod + 73
5   libobjc.A.dylib                 0x00007fff89345faa objc_msgSend + 198
6   libawt_lwawt.dylib              0x0000000116528ca4 JNI_OnLoad + 412
7   libjava.dylib                   0x00000001004c7c49 Java_java_lang_ClassLoader_00024NativeLibrary_load + 208
8   ???                             0x00000001027474d4 0 + 4336153812
9   ???                             0x000000010273b98d 0 + 4336105869
10  ???                             0x000000010273b160 0 + 4336103776
11  ???                             0x000000010273b98d 0 + 4336105869
12  ???                             0x000000010273b98d 0 + 4336105869
13  ???                             0x00000001027344e7 0 + 4336076007
14  libjvm.dylib                    0x0000000101ad4442 JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*) + 1710
15  libjvm.dylib                    0x0000000101b094bb jni_invoke_static(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*) + 447
16  libjvm.dylib                    0x0000000101b027ed jni_CallStaticVoidMethodV + 232
17  libjava.dylib                   0x00000001004d49cb JNU_CallStaticMethodByName + 282
18  libawt.dylib                    0x00000001163bb337 AWT_OnLoad + 547
19  libawt.dylib                    0x00000001163bb384 JNI_OnLoad + 9
20  libjava.dylib                   0x00000001004c7c49 Java_java_lang_ClassLoader_00024NativeLibrary_load + 208
21  ???                             0x00000001027474d4 0 + 4336153812
22  ???                             0x000000010273b98d 0 + 4336105869
23  ???                             0x000000010273b160 0 + 4336103776
24  ???                             0x000000010273b98d 0 + 4336105869
25  ???                             0x000000010273b98d 0 + 4336105869
26  ???                             0x000000010273b98d 0 + 4336105869
27  ???                             0x000000010273b710 0 + 4336105232
28  ???                             0x00000001027344e7 0 + 4336076007
29  libjvm.dylib                    0x0000000101ad4442 JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*) + 1710
30  libjvm.dylib                    0x0000000101b2ade2 JVM_DoPrivileged + 1208
31  ???                             0x00000001027474d4 0 + 4336153812
32  ???                             0x000000010273b710 0 + 4336105232
33  ???                             0x000000010273b98d 0 + 4336105869
34  ???                             0x00000001027344e7 0 + 4336076007
35  libjvm.dylib                    0x0000000101ad4442 JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*) + 1710
36  libjvm.dylib                    0x0000000101aa92b5 InstanceKlass::call_class_initializer_impl(instanceKlassHandle, Thread*) + 191
37  libjvm.dylib                    0x0000000101aaa797 InstanceKlass::initialize_impl(instanceKlassHandle, Thread*) + 1479
38  libjvm.dylib                    0x0000000101aaaa19 InstanceKlass::initialize(Thread*) + 61
39  libjvm.dylib                    0x0000000101ba674a LinkResolver::resolve_static_call(CallInfo&, KlassHandle&, Symbol*, Symbol*, KlassHandle, bool, bool, Thread*) + 156
40  libjvm.dylib                    0x0000000101ba695e LinkResolver::resolve_invokestatic(CallInfo&, constantPoolHandle, int, Thread*) + 258
41  libjvm.dylib                    0x0000000101ba6a1f LinkResolver::resolve_invoke(CallInfo&, Handle, constantPoolHandle, int, Bytecodes::Code, Thread*) + 179
42  libjvm.dylib                    0x0000000101ace819 InterpreterRuntime::resolve_invoke(JavaThread*, Bytecodes::Code) + 881
43  ???                             0x00000001027533ba 0 + 4336202682
44  ???                             0x000000010273b98d 0 + 4336105869
45  ???                             0x000000010273b710 0 + 4336105232
46  ???                             0x000000010273b7e4 0 + 4336105444
47  ???                             0x000000010273b710 0 + 4336105232
48  ???                             0x000000010273b98d 0 + 4336105869
49  ???                             0x00000001027344e7 0 + 4336076007
50  libjvm.dylib                    0x0000000101ad4442 JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*) + 1710
51  libjvm.dylib                    0x0000000101b094bb jni_invoke_static(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*) + 447
52  libjvm.dylib                    0x0000000101b026b5 jni_CallStaticVoidMethod + 349
53  libjli.dylib                    0x00000001000360ea JavaMain + 2456
54  libSystem.B.dylib               0x00007fff8a4e5fd6 _pthread_start + 331
55  libSystem.B.dylib               0x00007fff8a4e5e89 thread_start + 13

有什么想法吗?

JRE/JDK 8 需要 OS X 10.8(山狮)或更高。 http://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jre.html#A1098497

JRE/JDK 7 需要 OS X 10.7(狮子)或更高。 http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jre.html#requirements

我通常做的是创建应用程序的第二个版本以 JRE 6 为目标,它在 OS X 10.7 之前是系统包含的(或在需要时自动下载)。我不以 JRE 8 为目标,而只以 JRE 7 为目标,因此您只需要拥有两个版本的应用程序即可覆盖绝大多数 OS X 用户。