简体   繁体   中英

java.lang.ClassNotFoundException: can't successfully load the class source

I am working on an Android project - so far so good. Today I added some extra Java code to the project - I will call it here calcCode. This is some code doing calculations in the background and is not Android specific - I will just be using it in my project.

I added that new code to a different package than my Android code under the same project.

So what I have is:

Project
 AndroidPackage
  AndroidCode
 SomeJaveCodePackage
  UtilityCode

For some reason, when I try to debug the calcCode I get this annoying source not found error. Still - the code runs and delivers the correct results as always. I took the calcCode from some other project and copied the files into my new Android project. When I couldn't see the source I deleted all the calcCode files and manually created them by first creating a class file under the relevant package and then copy-pasted the code in. I thought this will help Eclipse recognize the path of the classes.

I also tried to: "Edit Source Lookup Path" and add the source code of the class I was trying to debug.

This didn't change anything - I can still not debug the code. I read several answers to this issue on StackOverflow. Most deal with Junit and Tomcat and I followed their recommendations but it didn't change the situation.

Anyone knows why this is happening?

I have Eclipse Indigo.


EDITED after m0skit0's remarks: Thank you m0skit0 for the help. I meant to ask only one question (I might have mixed up stuff on the way). My question is: Why can't Eclipse find my own code while I debug it. It used to work in a former project (that I was able to follow the code through all the app's course during debug).

What I do is set a break point at

Tour myTour = new Tour("res/raw/td.csv", "readCSV");

Tour is my own hand-made class. When I press F5 in order to step into it I get the error: java.lang.ClassNotFoundException and in the code window I get Source not found and a button Edit source lookup path.

This is the call stack:

Thread [main] (Suspended)
    ClassNotFoundException(Throwable).<init>(String, Throwable) line: 286   
    ClassNotFoundException(Exception).<init>(String, Throwable) line: not available 
    ClassNotFoundException(ReflectiveOperationException).<init>(String, Throwable) line: not available  
    ClassNotFoundException.<init>(String) line: not available   
    URLClassLoader$1.run() line: not available  
    URLClassLoader$1.run() line: not available  
    AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available [native method]   
    Launcher$ExtClassLoader(URLClassLoader).findClass(String) line: not available   
    Launcher$ExtClassLoader(ClassLoader).loadClass(String, boolean) line: not available 
    Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available 
    Launcher$AppClassLoader.loadClass(String, boolean) line: not available  
    Launcher$AppClassLoader(ClassLoader).loadClass(String) line: not available  
    TestAllPlayAll.main(String[]) line: 15  

Thanks, D

The problem is solved. The sad thing is that I don't know the solution. What I did was simply to open a new project and use the code there. After I did this i could debug the code with no problem.

Sorry I couldn't contribute to REALLY solving this issue and help the community with the answer to my own question.

Thanks to all that tried to help, D.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM