Java – Eclipse – source not found

I know this problem has been asked many times, but no proposed solution has solved my problem (or I haven't implemented it correctly)

I am developing a plug-in for openfire. When I set a breakpoint in my plug-in source, eclipse reports "source not found" Jar and openfire server are built separately I tried to add jars and specify the source directory, but there were no dice

The following is the process I pay attention to: when I click my breakpoint, click "Edit source search path", click "add", Java library, user library, click user library, add my library (try "add jar" and "add external jar"), and then specify the folder containing the source code I've also tried:

>Add source code by selecting file system directory instead of Java library > add it by selecting workspace folder > in Project Explorer, add the source of the plug-in to Java build path > in Project Explorer, add my jar as a library and specify the source attachment

Thank you in advance for any suggestions

Solution

Personally, I have no good experience in adding source folders in eclipse JDT What I always like to do is add source folders before debugging:

>Select project / properties / Library > select your library, and then "Edit..." source attachment > select the appropriate source folder or zip / jar containing the package

After that, you should be able to open the source file in the virtual "reference libraries" folder (directly under the "JRE system libraries" folder in the project), or open the reference to the linked class file in the JDT editor If you have access to the source code, you should also be able to stop and view the source code at least at the breakpoint

Otherwise, you will have to check again if the source folder is really valid: the source folder or source folder must contain the root package name of the library (for example, the default Java "Src. Zip" folder in the JDK also includes a corresponding "Java" folder in its root directory) If in doubt, extract the archive and select the parent folder of the package you are interested in - sometimes the source archive may be a mess or incompatible with JDT

If this has been determined and still does not work, the source folder you are linking does not correspond to the compiled version of the library Usually, JDT will handle this inconsistency, but if you try to open a source file, which is completely different from the corresponding class file, you will encounter problems In this case, I recommend that you download the correct source code version of the library, or recompile the library from the source file if all other programs fail

If it works normally to open the referenced source file using the JDT editor, and the source file still cannot be opened when a breakpoint is entered during debugging, it is likely that the class file is missing the line numbers of the corresponding source file Similarly, in this case, you will have to recompile the library from the source

Finally, you can override the default source lookup by specifying a source folder or archive in the source tab of the launch configuration However, you usually don't need to do this when your build path is configured correctly From the eclipse help:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>