日期:2014-05-20  浏览次数:20881 次

急,请问如何解决:Exception in thread "main"java.lang.NoClassDefFoundError: org/eclipse/jface/viewers/ISelectionChangedListener
自已编译一个SWT的应用,可是调用不了,命令行下报错如下,请各位大侠帮忙看看怎么回事?

D:\zmrj>java -jar zmrj.jar -Djava.library.apth=.;.\lib form.MainWindow

Exception in thread "main"java.lang.NoClassDefFoundError:
org/eclipse/jface/viewers/ISelectionChangedListener

Caused by: java.lang.ClassNotFoundException: org.eclipse.jface.viewers.ISelectio
nChangedListener
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClassInternal(Unknown Source)

D:\zmrj>


------解决方案--------------------
是不是没有把 swt的jar包放到 classpath去啊??
------解决方案--------------------
org.eclipse.swt.win32.win32.x86_3.2.2.v3236.jar文件在当前目录就可以了,但是前提是org.eclipse.swt.win32.win32.x86_3.2.2.v3236.jar中org/eclipse/jface/viewers/ISelectionChangedListener 

如果org.eclipse.swt.win32.win32.x86_3.2.2.v3236.jar在.\lib中,你可以这样运行:
D:\zmrj>java -cp .;.\lib\org.eclipse.swt.win32.win32.x86_3.2.2.v3236.jar -jar zmrj.jar -Djava.library.path=.;.\lib form.MainWindow 

在eclispe中,这个jar文件已经在classpath中了