我一直在努力,其目的是部署爲Java Web Start的,因此在多個平臺上使用基於SWT項目的正常運行基於SWT,跨平臺的罐子。在Mac
到目前爲止,我已經成功地處理那些產生是由於系統特定的庫SWT依賴於出口的問題(參見相關thread)。得到的罐子似乎工作開始64分之32位Linux和64位Windows罰款,但執行的Mac上失敗,出現以下的輸出:
$ java -jar dist/test.jar
Adding { file:/Volumes/LaCie/ChiBE_Local/swt/swt-cocoa-macosx-x86_64-3.6.1.jar } to the classpath
***WARNING: Display must be created on main thread due to Cocoa restrictions.
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.ExceptionInInitializerError
at org.eclipse.gef.tools.MarqueeSelectionTool.<init>(MarqueeSelectionTool.java:99)
at org.gvt.MarqueeZoomTool.<init>(MarqueeZoomTool.java:16)
at org.gvt.action.MarqueeZoomToolAction$1.<init>(MarqueeZoomToolAction.java:28)
at org.gvt.action.MarqueeZoomToolAction.createTool(MarqueeZoomToolAction.java:28)
at org.gvt.action.AbstractGEFToolAction.<init>(AbstractGEFToolAction.java:24)
at org.gvt.action.MarqueeZoomToolAction.<init>(MarqueeZoomToolAction.java:20)
at org.gvt.TopMenuBar.createBarMenu(TopMenuBar.java:113)
at org.gvt.ChisioMain.createMenuManager(ChisioMain.java:617)
at org.eclipse.jface.window.ApplicationWindow.addMenuBar(ApplicationWindow.java:235)
at org.gvt.ChisioMain.main(ChisioMain.java:149)
at org.gvt.RuntimeMain.main(RuntimeMain.java:14)
... 5 more
Caused by: org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.widgets.Display.error(Unknown Source)
at org.eclipse.swt.widgets.Display.createDisplay(Unknown Source)
at org.eclipse.swt.widgets.Display.create(Unknown Source)
at org.eclipse.swt.graphics.Device.<init>(Unknown Source)
at org.eclipse.swt.widgets.Display.<init>(Unknown Source)
at org.eclipse.swt.widgets.Display.<init>(Unknown Source)
at org.eclipse.swt.widgets.Display.getDefault(Unknown Source)
at org.eclipse.swt.widgets.Display$1.run(Unknown Source)
at org.eclipse.swt.graphics.Device.getDevice(Unknown Source)
at org.eclipse.swt.graphics.Resource.<init>(Unknown Source)
at org.eclipse.swt.graphics.Cursor.<init>(Unknown Source)
at org.eclipse.draw2d.Cursors.<clinit>(Cursors.java:170)
... 16 more
我也查了一些相關的線程(Can't get SWT Display on Mac OS X ,Problems With SWT on Mac)以及所述UI Thread entry on the SWT FAQ和教程如Bringing your Java App to Mac和Deploying SWT applications on Mac OSX。
我的理解是問題來自Mac OSX上的線程處理,我應該嘗試在執行時實現JVM參數-XstartOnFirstThread
。這是正確的嗎?
假設我對這個問題的理解是正確的,我有點困惑,因爲這個軟件旨在跨平臺和運行javaws的。我是否需要創建一個info.plist
文件,如果是的話,其中的包怎麼樣,否則我怎麼能「有條件」通過這樣的說法在執行時JVM的?
由於提前,
對於它的價值,我改進了錯誤信息:https://bugs.eclipse.org/bugs/show_bug.cgi?id = 470174 ***警告:由於Cocoa,必須在主線程上創建顯示限制。使用vmarg -XstartOnFirstThread – 2017-07-04 21:14:30