NoClassDefFoundError when running Netbeans 6.8 application

回眸只為那壹抹淺笑 提交于 2019-12-13 01:40:55

问题


My application has recently started throwing NoClassDefFoundError errors when I am running my application from within NetBeans. It never used to do this.

And when I run this outside of NetBeans using the command line argument that it provides once built, these errors are not produced

Is this a bug with Netbeans?

I have reinstalled NetBeans as I recently had another that was resolved by reinstalling, however the problem still persists.

Symbol error in java application using netbeans 6.8 when adding a shared project to library

Within Netbeans

alt text http://inverse.seednet.eu/snaps/ojtjal.png

Outside NetBeans alt text http://inverse.seednet.eu/snaps/gdwb5y.png


回答1:


The issue is the run time classpath of the run configuration when you are running it from netbeans. Make sure your run config has the jar containing these classes




回答2:


My solution consisted of setting the Main Class in Project Properties/Run. In that window click Browse to see all classes. In my case the main class was gone, to get it to reappear I added a syntax error to the main class, rebuilt, corrected the mistake, rebuilt, and then I was able to set the main class properly.




回答3:


So I had this problem as well. I read Temp_user's solution above, and did something similar, though my main class was present in Project Properties/Run. My program consisted of four separate classes. After going through each, adding a syntax error, clean and build, correcting the syntax error and cleaning and building again, the program works. I don't really understand how this fixed anything. Any insight would be appreciated.




回答4:


I had the same problem, NoClassDefFoundError out of the blue. What seems to have caused the problem in my case was initializing a Handler in a static Context. Although i have done this succesfully before. this specific instance caused the following exception:

10:45:08.196    19376   com.certhon.activities  ERROR   QualiflexApp    Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

Solving this also solved the NoClassDefFoundError, maybe the the handler causes app initialization to malfunction or something?

Im not very sure what went wrong or if this will help anyone, but, can't hurt to share right?




回答5:


We had jar-library correctly added to Project Libraries and working fine. Then, suddenly, it stopped working with this error.

To solve:

 1. Delete build and dist folders in the Project.
 2. Remove and add the library back to Project - Libraries. 
 3. Rebuild Project.


来源:https://stackoverflow.com/questions/2702185/noclassdeffounderror-when-running-netbeans-6-8-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!