1

I'm developing a Java application that uses the JD Native Swing WebBrowser control, while the application runs correctly on Windows, it doesn't run correctly on Mac. As I know, to run SWT Controls, I have to reference the Mac version of swt.jar (done), I also tried the -XstartOnFirstThread argument, but when used, the whole application doesn't start.

The application is composed by a Login screen made using Swing JFrame. Then when the login is successfull, the JFrame login is disposed. The SWT WebBrowser control should show up, but instead an exception is thrown.

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

Do you have any solution for it? I am pretty sure that running -XstartOnFirstThread could solve it, but doesn't run.

:-) Thanks for your help.

Joe C
  • 15,324
  • 8
  • 38
  • 50

0 Answers0