在Mac OS上如何運行jar文件


 問題 1:

% java -jar TASTS-MacOS-X64.jar
***WARNING: Display must be created on main thread due to Cocoa restrictions.
Exception in thread "main" org.eclipse.swt.SWTException: Invalid thread access
    at org.eclipse.swt.SWT.error(SWT.java:4533)
    at org.eclipse.swt.SWT.error(SWT.java:4448)
    at org.eclipse.swt.SWT.error(SWT.java:4419)
    at org.eclipse.swt.widgets.Display.error(Display.java:1089)
    at org.eclipse.swt.widgets.Display.createDisplay(Display.java:840)
    at org.eclipse.swt.widgets.Display.create(Display.java:823)
    at org.eclipse.swt.graphics.Device.<init>(Device.java:129)
    at org.eclipse.swt.widgets.Display.<init>(Display.java:722)
    at org.eclipse.swt.widgets.Display.<init>(Display.java:713)
    at org.eclipse.swt.widgets.Display.getDefault(Display.java:1419)
    at MainForm.main(MainForm.java:10)

解決方法:

java -XstartOnFirstThread -jar TASTS-MacOS-X64.jar

 

問題 2:

java -XstartOnFirstThread -jar TASTS-MacOS-X64.jar
Unable to create basic Accelerated OpenGL renderer.
Unable to create basic Accelerated OpenGL renderer.
Core Image is now using the software OpenGL renderer. This will be slow.

不知道是否相關...但是我只是刪除了一些窗口事件綁定(beforeunloadquit),現在不再看到此問題。(至少現在)。不確定如何將兩者鏈接起來,但以防萬一!

 解決方法:

(Deploying SWT Applications on Mac OS X)

https://www.eclipse.org/swt/macosx/

https://blog.csdn.net/javaee_gao/article/details/102833350

https://stackoverflow.com/questions/22926289/using-swt-under-osx

https://eclipsesource.com/blogs/2012/07/19/configuring-the-os-x-application-menu-for-swt-apps/

https://mchr3k.github.io/swtjar/osxapp.html

https://stackoverflow.com/questions/19803332/menu-doesnt-show-up-with-swt-on-mac-os-x

 

REF

https://blog.csdn.net/u011686226/article/details/83143173

 http://www.cocoachina.com/articles/446513

https://blog.csdn.net/u011686226/article/details/83143173

在Run Configurations -> Arguments -> VM arguments設置中加入:-XstartOnFirstThread


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM