开发者

eclipse export jar java.lang.NoClassDefFoundError problem

When compile and run using eclipse there is no problem , but when I exported as jar with these setting , i got Exception in thread "AWT-EventQueue-0" 开发者_高级运维java.lang.NoClassDefFoundError: gnu/io/SerialPortEventListener .

The jar exporter didn't export my extended jar library?

eclipse export jar java.lang.NoClassDefFoundError problem

eclipse export jar java.lang.NoClassDefFoundError problem


This sentence from the Exceptions JavaDoc helps to understand what went wrong:

The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.

You've build the application on eclipse with no errors. So the classpath definition inside eclipse was good enough to compile all classes.

Now you export it, run it out of eclipse and encounter that error. The exported application does not use the eclipse projects classpath definition any more. And the currrent one does not include the library which contains the gnu.io.SerialPortEventListener.

The general solution is: fix the classpath problems for the exported jar.


It could be a dependency issue, however, don't confuse ClassNotFoundException and NoClassDefFoundError. Basically, it is saying there was a problem in the initialization of: gnu/io/SerialPortEventListener I would check that class for errors as a starting point.


I have solve it by using fatjar


You may also consider using the open source tool called WinRun4J .

This is available at http://winrun4j.sourceforge.net/ .

I found this easy and effective to use .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜