在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.
不知道是否相关...但是我只是删除了一些窗口事件绑定(beforeunload
,quit
),现在不再看到此问题。(至少现在)。不确定如何将两者链接起来,但以防万一!
解决方法:
(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
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步