Class not found exception

I am using Eclipse; when i run my code in debug i get class exception but don't run without debugging it works fine.
I can see that it does not find the classes that I wrote.

How can I fix this?

0


a source to share


4 answers


Make sure the Run Configuration in Eclipse has the same classpath as for both (runs fine and debug).



+2


a source


Eclipse has a lot of settings, but I would try to check the following:

Run > Debug Configurations > Java Application > PROJECT_NAME > Classpath

      



Alternatively, you can check your source in the same location to make sure all your JAR files were added correctly.

+1


a source


I am assuming we are looking at a normal Java application. Eclipse creates Run Configurations for normal execution and Debug Configurations for debug launches. And there is usually no significant difference between Run and Debug configuration for the same class.

The easiest way is to start cleaning: go to "Run Configs ..." and delete all Java Application configurations. Then do the same for "Debug Configuration". Then run the application once in normal mode and once in debug mode.

Alternative: go to a new workspace (File -> Switch Workspace), import the project (File -> Import ..., be sure to copy the content) and run / debug the app.

0


a source


Check your startup / startup settings. You probably have a different configuration to debug and run. Most likely the debugger does not point to the main class of your program.

Just check the debug ... option (pull down the debug menu, don't click the button, then click "Debug ...") and the first page should have a "Main Class" field. Use the same main class as in your run parameter ...

0


a source







All Articles