如何在终端中成功打开SWT jar文件

时间:2014-05-24 13:50:36

标签: java jar terminal swt osx-mavericks

当我试图在终端(OS X 64位)中打开一个jar文件时,我收到了下一条消息:

我应该怎么做才能打开文件?

software1 bktomer $ java -jar MusicTunes.jar

***警告:由于Cocoa限制,必须在主线程上创建显示。

线程“main”中的异常org.eclipse.swt.SWTException:无效的线程访问

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 il.ac.tau.cs.sw1.musictunes.ui.GraphicalMusicTunesViewer.createShell(GraphicalMusicTunesViewer.java:63)
at il.ac.tau.cs.sw1.musictunes.ui.GraphicalMusicTunesViewer.show(GraphicalMusicTunesViewer.java:55)
at il.ac.tau.cs.sw1.musictunes.ui.GraphicalMusicTunesViewer.showViewer(GraphicalMusicTunesViewer.java:38)
at il.ac.tau.cs.sw1.musictunes.ui.GraphicalMusicTunesViewer.main(GraphicalMusicTunesViewer.java:33)

1 个答案:

答案 0 :(得分:1)

在OS X上运行SWT程序时,必须指定-XstartOnFirstThread选项:

java -XstartOnFirstThread -jar MusicTunes.jar