Attach the Source in Eclipse of a jar
A .jar file usually only contains the .class files, not the .java files they were compiled from. That's why eclipse is telling you it doesn't know the source code of that class.
"Attaching" the source to a JAR means telling eclipse where the source code can be found. Of course, if you don't know yourself, that feature is of little help. Of course, you could try googling for the source code (or check wherever you got the JAR file from).
That said, you don't necessarily need the source to debug.
No source attachment in Java
The .jar file is the generated packed classes of the java code. Some jars will come with java doc and code and others won't.
For recent Eclipse versions:
right-click the jar in question (in the referenced jars, not the physical jar) and choose Preferences -> Javadoc. Here give a correct location (zip/URL) to the correct javadoc. (Select Validate!)
For older Eclipse versions:
First: Navigate to the jar itself in the Eclipse project explorer (to the left) and try to open aclass of the jar. Then, you will see the warning that it has no source attachment, and a button to attach the source code.
Then, push the button, select "external folder" and then navigate to the folder with source you already have.
How do I attach source code into a project's library in Eclipse?
First of all, there's nothing to be debuged at @Autowire is just an annotation. The only thing you will see there is its attributes. That's it. The interesting code is in AutowiredAnnotationBeanPostProcessor.java
Anyways, if you want to attach source zips to a jar. In Eclipse is as easy as:
- Your Project (Right Click) > Preference
- Select Java Build path (Left menu) > Libraries (Tab)
- Look for the jar an do click on its arrow
- Select source attachement
Here an example of the process.
If you are insterested on how Annotations works. I suggest this tutorial Java Tutorial - Annotations.
In Eclipse, how to attach different source files when debugging
In the Debug view, select the Debug tab. Right click your debug instance and choose "Edit source lookup..."
See below:
Be sure to run a Project Clean after changing the source lookup. I have run into many inconsistencies in various versions of Eclipse with this feature.
How to attach source or JavaDoc in eclipse for any jar file e.g. JavaFX?
You can configure the Javadocs with downloading jar, basically javadocs will be referred directly from internet.
Complete steps:
- Open the Build Path page of the project (right click, properties,
Java build path). - Open the Libraries tab.
- Expand the node of the library in question (JavaFX).
- Select JavaDoc location and click edit.
- Enter the location to the file which contains the Javadoc.
Specifically for the javaFX javadoc enter http://docs.oracle.com/javafx/2.0/api/
for offline javadocs, you can download from : http://www.oracle.com/technetwork/java/javase/documentation/java-se-7-doc-download-435117.html
After clicking Accept License Agreement you can download javafx-2_2_0-apidocs.zip
How to attach source in Eclipse project for lib with no sources JAR ?
I just tried it in my workspace and was able to resolve the source files properly. The trick is that when you select the external location, you should pick the 'external Folder' instead of 'External File'.
I selected the External Folder with path cas-server-4.0.0/cas-server-core/src and it worked.
Attach the Java Source Code
Normally, if you have installed the JDK6u14, eclipse should detect it and declare it automatically in its "installed JRE" list.
If not, you can add that JDK through "Windows/Preferences": Java > Installed JREs
:
Just point to the root directory of your JDK installation: it should include the sources of the JDK (src.zip
), automatically detected and attached to rt.jar
by eclipse.
Related Topics
Pure Java HTML Viewer/Renderer for Use in a Scrollable Pane
Android 6.0 Open Failed: Eacces (Permission Denied)
Iterating Over and Removing from a Map
How to Avoid Floating Point Precision Errors with Floats or Doubles in Java
Delete Directories Recursively in Java
Jackson - Deserialize Using Generic Class
Differencebetween "Class.Forname()" and "Class.Forname().Newinstance()"
Using Heapdumponoutofmemoryerror Parameter for Heap Dump for Jboss
How to Change Text Color in the Jtextarea
Adding Header for Httpurlconnection
Java Filewriter with Append Mode
How to Resize an Image Using Java
How to Tackle Daylight Savings Using Timezone in Java
Why Doesn't Java Support Unsigned Ints