tags:

views:

167

answers:

5

I'm using Eclipse; when I run my code in debug I get a class not found exception but running it without the debug it works fine.
I see it doesn't find the classes I wrote.

How can I fix this?

+2  A: 

Double-check that the Run Configuration in Eclipse has the same classpath set for both (running it normally vs debug).

matt b
A: 

Are your class libraries all set ok?

PSU_Kardi
+1  A: 

Eclipse has a lot of settings but I would try checking the following:

Run > Debug Configurations > Java Application > PROJECT_NAME > Classpath

Also, you can check your source under the same location to make sure all of your JAR files have been properly added.

Aaron K
A: 

I assume we're looking at a normal Java Application. Eclipse creates Run Configurations for normal execution and Debug Configurations for debug runs. And there's usually no significant difference between a Run and a Debug configuration for the same class.

The easiest way would be to start clean: Navigate to 'Run Configurations...' and delete all 'Java Application' configurations. Then do the same for 'Debug Configurations'. After this is done, start your application once in normal and once in debug mode.

Alternative: switch to a new workspace (File -> Switch workspace), import the project(s) (File -> Import... , make sure to copy content) and run/debug your application.

Andreas_D
A: 

Check your run/launch configurations. You probably have a different configuration for debug vs run. Chances are that the debug one isn't pointing 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 field for "Main class". Use the same main class as in your run... option.

Bill K