I'm trying to create a SWT application in eclipse. I've followed the instructions and loaded the org.eclipse.swt project to my workspace, and made it a dependency of my project by adding it to my build path.
However i cannot see the javadoc when i'm referencing the SWT libraries. I tried extracting the 'src.zip' into the org.eclipse.swt project, and then tried generating the Javadoc which created a 'doc' folder with a whole bunch of html files, so i think it's all there, it's just that eclipse isn't picking it up.
Can someone suggest anything please?
You shouldn't need to generate anything to get the Javadoc.
See if you can edit your SWT build classpath entry and attach the src.zip there. That should be enough to display the associated javadoc (like in this tutorial, except you can reference an external file src.zip instead of the external 'src' directory).
You shouldn't need to extract the zip or generate the Javadoc. I assume you followed the instructions listed here:
Developing SWT applications using Eclipse
I followed the same steps and was able to view the Javadocs in the Javadoc view tab. The tab is automatically updated whenever you click on a class you are instantiating in your code.
Related
I have built a library and linked it to my Eclipse project as an External JAR.
Though the library works well, I couldn't make the Javadoc I wrote appear, as Eclipse keeps showing me:
I've read through some similar posts and they all refer to the javadoc file location, but I have no separate file for Javadoc. Everything is written above fields and methods with basic annotations.
How am I supposed to "link" a javadoc that is already present in the library files ? Thank you.
You could export the jar, and in the export window you can mark the option export java source files and resources
I know this insn't the ideal fix(cause you would be exporting your source code) but it does work
I have added the Javax.mail library to my project, and added the jar files as Libraries and included the dependencies as well but still it displays "Sources not found" in the Javax.mail classes and wants me to attach sources. Help Plz
I'm not using Maven
When you add a library to IntelliJ IDEA, at a minimum you need to attach the JAR (or directory) containing the compiled classes (i.e. the binaries). You then can optionally add either the source code, the javadoc, or both. Javadoc can be added as a JAR file, a ZIP file, a directory, or as a URL. Source code can be added via a JAR file, a ZIP file, or a directory.
Adding either the Javadoc or the source file will allow you to see the libraries Javadoc documentation via the "View Quick Documentation" action (Ctrl+Q / ⌃J or View > Quick Documentation from the menu). Since the source code has the Javadoc source, IDEA can pull the Javadoc from it.
An additional added advantage of having the source code attached is that you can actually view the source code (via various actions like quick definition lookup Ctrl+Shift+I / ⌥Space or via the view menu, or the go to implementation or declaration actions).
With third party libraries, not all of them will have Javadoc and/or source code available. Some will have one or the other, some both, and some neither. Sometimes,you have to go hunting for the source code or Javadoc. The two best places to look are the project's home page and the Maven Central Repository (http://search.maven.org/). Even if you are not using maven to build your project, you can find and download binary, source, and javadoc for a lot of projects/libraries there making it a good resource.
If you go the the Maven Central, and do a search for javax mail, in the search results listing will be the javax.mail library. If you click the all link for it, you will get a listing of all the versions of the javax mail API available in maven central. Some have Javadoc and sources available (especially the most recent ones), some only sources, and some neither (mostly older releases).
So in this case, we can find the source, download it, and attach it. However, in some cases you will not be able to. Especially for propitiatory (i.e. non-open-source) software that does not release the source. That's OK. You simple loose the functionality to be able to view the source of a class. You know that and can ignore the warning.
I'm posting this query after doing lots of googling and trying out different options for last few days. Is there an easy way to attach source in Eclipse? is the closest answer I found to my question.
From above post, I tried all solutions but each time Eclipse is opening .class file instead of .java file.
Eclipse Details:
Kepler Service Release 2
Build id:20140224-0627
Please let me know if this is a bug with Eclipse or if I am missing something.
If you are using Maven, try this:
Double click on your project in eclipse -> Maven -> Enable Workspace Resolution
This is most likely because Eclipse actually use the class file for declaring the item you have requested the declaration for, and not the source file you think it should be using.
The typical reason for this is if you have a jar file containing previously compiled classes on your build path before (or instead) of the project containing the source you want. This is very rarely desirable as it can take quite a while to discover that your edits do not take effect.
Examine your build path carefully and ensure it is as you want it to be.
Maven is likely supplying a Classpath Container to your project, and generating entries for the Java Build Path based on the pom.xml contents (the JRE System Library is another example of this). Its entries will not have source attachment unless the container decides it will, which is why the Installed JREs preference page offers to let you set Source Attachments. If the pom.xml has something like that, see if you can use it. If not, see if you can configure the Maven container from its context menu. Otherwise, you may simply be stuck.
I had this same problem: when I pressed F3 or tried to open Declaration (after right click) for any element, it took me to the bytecode .class file.
My solution:
I went to the project in Project Explorer:
right click on project name->Properties
Then in Porject Properties window,
Java Build Path->"Order and Export" tab
There I selected the folder with the .java files (source code), which was below the folder having the .class files -in my case "JRE System Library [java-11-openjdk-amd64]", and pressed 'Top' button on the right frame. Then the folder with source files moved to the top.
Finally, pressed "Apply and Close" button.
That solved my problem forever and ever.
The folder
I installed a plug-in which allows me to download the sources for a maven project.
I'm not by my develop machine right now, but I think it was this:
http://marketplace.eclipse.org/content/m2e-dynamic-sources-lookup#.U8gjGWIaySM
With this, you can select a project an have maven download the sources and make then available when you navigate the code in Eclipse. All without "leaving" Eclipse.
Check into your project modules the Java Build Path, look inside the Source tab and verify if you have "Allow output folders for source folders" checkbox flagged; in this case you just need to uncheck it and you will be able to see again the right source from java files.
This is related to the Call Hierarchy in Eclipse IDE.
If you are in a situation, where you're seeing duplicate methods inside the call hierarchy showing Members calling 'myMethod(...)', double-clicking on one of the listed methods may open the .class file instead of the .java file.
When this happens, the solution is to set the search scope in the call hierarchy to Project instead of Workspace.
After setting the search scope, you won't be seeing duplicate methods listed in the call hierarchy, and double-clicking on the listed methods will only open the .java files.
(Using Eclipse DevStyle Dark Theme)
I added a Student.jar into my Build Path in my eclipse like this-
Right click on the project->BuildPath->Configure Build
Path->Libraries->Add External Jars
There is one class named StudentTest in Student.jar file. When I was debugging my code in eclipse, I stepped into that StudentTest class in the Student.jar.
And after that eclipse shows me like this-
The JAR file S:\some_location\Student.jar has no source attachment.
You can attach the source by clicking Attach Source below
Now I am not sure how should I attach the source in my eclipse. And from where? Can anyone provide me step by step what I need to do.
Update:-
I tried unzipping the Student.jar and I got Student folder. And after that I tried pointing the source to Student folder But still I am not able to see the class properly so that I can debug it properly, it shows the same above behavior.
Use Java Source Attacher !
It does what eclipse should do - a right click context menu that says "Attach Java Source.
It automatically downloads the source for you and attaches it. I've only hit a couple libraries it doesn't know about and when that happens it lets you contribute the url back to the community so no one else will have a problem with that library.
Eclipse is showing no source found because there is no source available . Your jar only has the compiled classes.
You need to import the project from jar and add the Project as dependency .
Other option is to go to the
Go to Properties (for the Project) -> Java Build Path -> Libraries , select your jar file and click on the source , there will be option to attach the source and Javadocs.
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.
This worked for me for Eclipse-Luna:
Right Click on the *.jar in the Referenced Libraries folder under your project, then click on Properties
Use the Java Source Attachment page to point to the Workspace location or the External location to the source code of that jar.
Go back in to where you added the jar. I believe its the libraries tab, I don't have Eclipse open but that sounds right. to the left of the jar file you added there should be an arrow pointing right, click that and 3 or 4 options expand, one of them being the source file of the library. Click on that and click edit(I think you can also double click it) then locate the file or folder on your hard disk, you probably have to click apply or okay and you're good to go, same with javadoc and i think the last one is native libraries. I don't pay much attention when I'm in there anymore if you couldn't tell. That's what you were asking, right?
I Know it is pretty late but it will be helpful for the other user, as we can do Job using three ways... as below 1)1. Atttach your source code using i.e, Right click on the project then properties --> Java build path--> attach your source in the source tab or you can remove jar file and attach the source in the libraries tab
2. Using eclipse source Analyzer In the eclipse market you can download the plugin java source analyzer which is used to attach the open source jar file's source code. we can achieve it after installing the plugin, by right click on the open source jar and select the attach source option.
3. Using Jadclipse in eclipse you can do it last not the least, you can achieve the decompile your code using this plugin. it is similar way you can download the plugin from the eclipse market place and install in your eclipse.
in jadclipse view you can see your .class file to decomplile source format note here you cannot see the comment and hidden things I think in your scenario you can use the option one and option three, I prefer option three only if i want to the source code not for the debug the code. else i ll code the option 1, as i have the source already available with.
Simply import the package of the required source class in your code from jar.
You can find jar's sub packages in
Eclipse -- YourProject --> Referenced libraries --> yourJars --> Packages --> Clases
Like-- I was troubling with the mysql connector jar issue
"the source attachment does not contain the source"
by giving the path of source folder it display this statement
The source attachment does not contain the source for the file StatementImpl.class
Then I just import the package of mysql connector jar which contain the required class:
import com.mysql.jdbc.*;
Then program is working fine.
I faced the same issue and solved using the below steps. Go to Windows->preferences->Editors->File Associations
Here click on Add
then type .class
click on OK
again click on Add
then type .classwithoughtsource
click on OK
Now you will be able to see JadClipse option under Java section in Windows->Preferences
Please provide the path of jad.exe file as shown below.
Path for Decompiler-C:\Users\ahr\Documents\eclipse-jee-galileo-SR2-win32\jad.exe
Directory for temporary Files-C:\Users\ahr.net.sf.jadclipse
click on Apply
Now you should be able to see the classfiles in proper format.
It is quite possible, just go to the jar in the Build Path and choose to attach a source just like follow.
Download JDEclipse from http://java-decompiler.github.io/
Follow the installation steps
If you still didn't find the source, right click on the jar file and select "Attach Library Source" option from the project folder, as you can see below.
I am using project is not Spring or spring boot based application.
I have multiple subprojects and they are nested one within another.
The answers shown here supports on first level of subproject.
If I added another sub project for source code attachement, it is not allowing me saying folder already exists error.
Looks like eclipse is out dated IDE. I am using the latest version of Eclipse version 2015-2019.
It is killing all my time.
My intension is run the application in debug mode navigate through the sub projects which are added as external dependencies (non modifiable).
I have faced same problem and resolved it by using following scenario.
First we have to determine which jar file's source code we want along with version number. For Example "Spring Core" » "4.0.6.RELEASE"
open https://mvnrepository.com/ and search file with name "Spring Core" » "4.0.6.RELEASE".
Now Maven repository will show the the details of that jar file.
In that details there is one option "View All" just click on that.
Then we will navigate to URL "https://repo1.maven.org/maven2/org/springframework/spring-core/4.0.6.RELEASE/".
there so many options so select and download "spring-core-4.0.6.RELEASE-sources.jar" in our our system and attach same jar file as a source attachment in eclipse.
Try removing the breakpoints. :)
I just downloaded Eclipse several hours ago, and needed to add Java3D to the classpath. Installing it went without a hitch, but Eclipse can't seem to find the documentation folders so that it can give super-IDE functionality, such as autocomplete and method signatures.
While I know how I would add them individually, this lead me to the question; what is the "correct" way to install a Java library in Eclipse? Is there a special directory format I should follow? Is there a plugin that already did this for me? (The answer to that is yes, but I don't know how to use it, or whether or not it's appropriate).
Thanks!
Edit 1: It seems to me that someone down-voted the question. May I ask why?
Edit 2: So after monkeying around with the JARs, it seems that manually setting the doc path for each JAR in the library seems to be the least-error prone way.
when you add a .JAR(library) to your project in the LIBRARIES tab for your project, you have the option of attaching the javadoc directory for the jar.
So, go to the LIBRARIES tab of the "java build path" for your projects. select your jar. expand the (+) sign and you will see that you can set the javadoc. path.
good luck,
I think I've got it (had the same issue as you). Better late than never.
Go here - http://java3d.java.net/binary-builds.html and download the documentation zip (j3d-1_5_2-api-docs.zip).
Extract the directory anywhere on your HD (Right in the Java3d folder is fine).
Link the Jar's JavaDoc listing to that Folder (java build path >> Libraries >> expand the Jar Listing >> JavaDoc Location >> browse to the folder location, then validate). Do it for each j3d Jar.
That should integrate the J3D Javadoc.
As far as I know (haven't used 3.4 very much thus far), Eclipse has two options for the automatic showing of Javadocs. The first is a JavaDoc jar to attach to the jar file. The second is having the javadoc in a source jar which is attached to the jar to show the source.
A directory, if I recall correctly, will not provide autocompletion of javadoc. However, if you press "F1", you will be able to access the javadoc via the help menu.
You might try placing the documentation directory into a jar file, and attaching it to the jar file and see if that tricks Eclipse.
I cheat; All my java projects are built with maven, so I use maven to generate an eclipse project, with classpaths etc already setup, with a simple 'mvn eclipse:m2eclipse'.