Java.lang.ClassNotFoundException: unable to load source code

I am working on an Android project - so far so good. Today I added some additional Java code to the project - I will call it calcCode here. This is some code that performs calculations in the background and is not dependent on Android - I will just use it in my project.

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

So, I have a:

Project AndroidPackage AndroidCode SomeJaveCodePackage UtilityCode 

For some reason, when I try to debug calcCode, I get this annoying source that was not found. However, the code runs and delivers the correct results, as always. I took calcCode from another project and copied the files to my new Android project. When I could not see the source, I deleted all calcCode files and manually created them, first creating a class file under the appropriate package, and then copying the code. I thought this would help Eclipse recognize the classpath.

I also tried: β€œChange the source search path” and add the source code of the class that I was trying to debug.

It hasn't changed anything - I still can't debug the code. I read some answers to this problem in StackOverflow. Most of them concern Junit and Tomcat, and I followed their recommendations, but this did not change the situation.

Does anyone know why this is happening?

I have an Eclipse Indigo.


EDITED after comments m0skit0: Thanks m0skit0 for the help. I wanted to ask only one question (I could mix up the material along the way). My question is: why Eclipse cannot find my own code while I debug it. He used to work in a previous project (that I was able to follow the code through the entire application course during debugging).

What I do sets a breakpoint at

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

The tour is my own handmade class. When I press F5 to enter it, I get an error: java.lang.ClassNotFoundException and in the code window I get Source not found and the Edit source lookup path button.

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

+4
source share
1 answer

The problem is resolved. The sad thing is that I do not know the solution. I just wanted to open a new project and use the code there. After that, I could debug the code without any problems.

Sorry, I was not able to contribute REALLY by resolving this issue and helped the community answer my own question.

Thanks to everyone who tried to help, D.

+2
source

Source: https://habr.com/ru/post/1410865/


All Articles