1

我正在开发一个使用 JD Native Swing WebBrowser 控件的 Java 应用程序,虽然该应用程序在 Windows 上正确运行,但在 Mac 上却无法正确运行。据我所知,要运行 SWT 控件,我必须引用 Mac 版本的 swt.jar(完成),我还尝试了 -XstartOnFirstThread 参数,但使用时,整个应用程序无法启动。

该应用程序由使用 Swing JFrame 制作的登录屏幕组成。然后当登录成功时,JFrame登录就被处理掉了。SWT WebBrowser 控件应该会显示出来,但会引发异常。

On Mac, "NativeInterface.initialize()"/"NativeInterface.open()" should
not be called after AWT static initializers have run, otherwise there
can be all sorts of side effects (non-functional modal dialogs, etc.).
Generally, the problem is when the "main(String[])" method is located
inside an AWT component subclass and the fix is to move that main
method to a standalone class. The problematic class here is
"scribo_formac.MainPage"
***WARNING: Display must be created on main thread due to Cocoa restrictions. 2016-11-22 13:41:54.037 java[797:f07] _createMenuRef
called with existing principal MenuRef already associated with menu
2016-11-22 13:41:54.038 java[797:f07] ( 0   CoreFoundation            
0x00007fff8ac9e0a6 __exceptionPreprocess + 198 1   libobjc.A.dylib    
0x00007fff918613f0 objc_exception_throw + 43 2   CoreFoundation       
0x00007fff8ac9de7c +[NSException raise:format:] + 204 3   AppKit      
0x00007fff8d937eac -[NSCarbonMenuImpl _createMenuRef] + 62 4   AppKit 
0x00007fff8d9377fb -[NSCarbonMenuImpl _instantiateCarbonMenu] + 143 5 
AppKit                              0x00007fff8d936743 -[NSApplication
finishLaunching] + 778 6   libosxapp.dylib                    
0x00000001a9b61e5a -[NSApplicationAWT finishLaunching] + 683 7  
libswt-pi-cocoa-4626.jnilib         0x00000001dbf746e9
Java_org_eclipse_swt_internal_cocoa_OS_objc_1msgSendSuper__Lorg_eclipse_swt_internal_cocoa_objc_1super_2J + 153 8   ???                                 0x000000010b6c83b4 0x0 + 4486628276 )
_NSJVMLoadLibrary: NSAddLibrary failed for /libjawt.dylib JavaVM FATAL: lookup of function JAWT_GetAWT failed. Exit

你有什么解决办法吗?我很确定运行 -XstartOnFirstThread 可以解决它,但不会运行。

:-) 谢谢你的帮助。

4

0 回答 0