I am using a third party library, i have included into my project. It contains classes for the application, but no sources, or Javadoc. As expected, mouse-over imported object shows no javadoc.
Note: This element neither has attached source nor attached
Javadoc and hence no Javadoc could be found.
After googling for a bit, i came across 3 versions of jars
app.jar
app-sources.jar
app-javadoc.jar
It appears and app-javadoc.jar contains nothing but html pages and app-sources contans nothing but .java files (with Javadoc comments).
What i did:
Added all 3 files to the list of
"Referenced Libraries". After
"refresh"ing the project, javadoc
still does not show.
Additionally, under properties for
the project, i pointed "Javadoc
location path" to unzipped content of
app-javadoc.jar (validated ok)
Still, after having done all that, my Eclipse fails to display javadoc.
Please advise
Thank you.
Add only app.jar to the Referenced Libraries.
then, go to Project Explorer, right click on the jar file-> Properties -> Javadoc Location and add Javadoc jar location (app-javadoc.jar).
If you want to also browse the source code, then go to 'Java Source attachment' in the same dialog box and add the app-sources.jar there.
I think you should set the javadoc location to the library itself but not the Project's javadoc location property.
Project > Properties > Java Build Path > Libraries
expand the app.jar node and select the "Javadoc location" sub node and you can see the "Edit" button at the right of the library tree is enabled. Then click the "Edit" button and you can choose your javadoc in a jar file.
I am using Eclipse not MyEclipse but I think they are similiar. FYI
Here is an answer as of 2016-05-12:
In the Eclipse Project Explorer, under Referenced Libraries, right click on the jar file for which you require documentation. In the present example I require documentation for the Apache Commons IO library.
Select Properties. Then select Javadoc Location:
In the case that I am considering--the Apache Commons IO library--the javadoc jar file is stored in the same directory as the library jar file. In the Properties dialog, select Javadoc in Archive, navigate to the relevant directory, and click on the javadoc jar file:
Click Open, click OK, and you're done. As shown below, when you hover your cursor over an Apache Commons IO class name the javadoc appears:
Related
I generated my package mypackage.jar and mypackage-javadoc.jar.
And then I followed instruction here.
I created mypackage.jar.properties and inside
doc=docs/mypackage-javadoc.jar
now I placed my package in libs and javadoc jar file into libs/docs/
and then when I import mypackage.jar into my project.
it still says 'This element neither has attached source nor attached Javadoc and hence no Javadoc could be found'.
Is there anyway to sync javadoc with my class files automatically when I just import mypackage.jar?
Yo don't need a properties file. Make sure your JAR is added to the classpath of the project (Right click, Properties, Java Build Path).
Then you should see your Jar under the project's node in the tree with a little jar icon next to it. Right-click on it, properties and there is a GUI for setting the Javadoc location.
Click on Javadoc location and then Edit...
Enter the path to your javadoc JAR.
I know how to add .java/class files to a certain project, or import them into a package. So, when you're using eclipse you can import java.awt.; and java.util.; and the but those are all packages inside the JRE. So my real question is: is there any way to import a package containing the files i want into the JRE so that, if i create a new project, I can simply import them whenever I need them? Thanks!
Yes. Generally, you have more then one choice. You can link the project(s) in eclipse, and then have project B with a reference to project A. Or, you can create a build artifact like a jar file and add it to the project B build/run path. Simply add a jar file to your project, right click and select Add to Build Path. Another alternative is to use a build tool that manages dependencies like gradle, sbt, maven, or apache ivy. Note that there are a wide variety of third-party opensource libraries you can add as dependencies using these (and other) tools.
You seem to be asking how to create a shared library, which in Java is a .jar file. The steps to do this in Eclipse are:
In the Package Explorer, you can optionally pre-select one or more Java elements to export. (These will be automatically selected in the Opens the JAR export wizard JAR Package Specification wizard page, described in Step 4.)
Either from the context menu or from the menu bar's File menu, select Export.
Expand the Java node and select JAR file. Click Next.
In the JAR File Specification page, select the resources that you want to export in the Select the resources to export field.
Select the appropriate checkbox to specify whether you want to Export generated class files and resources or Export Java source files and resources. Note: Selected resources are exported in both cases.
In the Select the export destination field, either type or click Browse to select a location for the JAR file.
Select or clear the Compress the contents of the JAR file checkbox.
Select or clear the Overwrite existing files without warning checkbox. If you clear this checkbox, then you will be prompted to confirm the replacement of each file that will be overwritten.
Note: The overwrite option is applied when writing the JAR file, the JAR description, and the manifest file.
You have two options:
Click Finish to create the JAR file immediately.
Click Next to use the JAR Packaging Options page to set advanced options, create a JAR description, or change the default manifest.
Credit goes to the docs.
I know this question has been asked many times before, but none of the proposed solutions resolve my issue (or I'm not implementing them correctly).
I'm developing a plugin for OpenFire, and when I set a breakpoint in my plugin source Eclipse reports "Source not found". The JAR is built separate from the build of the OpenFire server. I've tried adding the JAR and specifying the source code directory, but no dice.
Here's the process I'm following: When I hit my breakpoint I'm clicking "Edit Source Lookup Path", clicking "Add", Java Library, User Library, click User Libraries, adding my library (tried both "Add JARs" and "Add External JARs"), and then specifying the folder that contains the source code. I've also tried:
Adding the source by selecting "File System Directory" instead of "Java Library"
Adding it by selecting "Workspace Folder"
In the Project Explorer, adding the source for my plugin to the Java Build Path
In the Project Explorer, adding my JAR as a Library and specifying the Source attachment
Thanks in advance for any suggestions.
Personally, I have no good experience in Eclipse JDT, when adding a source folder at the time it hits a break point. What I always prefer to do, is adding the source folder before debugging:
Select Project/Properties/Libraries
Select your library and "edit..." the source attachment
Select either the corresponding source folder or the zip/jar containing the package
After that, you should be able to open the source files in the virtual "Referenced Libraries" folder (directly below the "JRE System Library" folder inside the project), or when opening a reference to a linked class file from within the JDT editor. If you are able to access the source, then you should also be able to at least stop at the break point and see the corresponding source.
Else, you will have to check again, if the source folder is really valid: The source folder or source archive must contain the folder with the name of the root package of the library (e.g. the default Java "src.zip" inside the JDK folder also includes a corresponding "java" folder at its root). When in doubt, extract the archive and select the parent folder of the package you are interested in - sometimes source archives might be a mess or incompatible to JDT.
If this has been assured and it still doesn't work, chances are, that your linked source folder does not correspond to the compiled version of the library. Usually JDT will handle such inconsistencies fine, but if you try to open a source file, that is entirely different than the corresponding class file, you will encounter problems. In this case I would suggest either downloading the correct source version of the library, or recompiling the library from the source, if all else fails.
If opening a referenced source file from withing the JDT editor does work fine, and you are still unable to open the source files when a break point is entered during debugging, then most likely the class files are missing the line numbers of the corresponding source file. Again, you will have to recompile the library from the source in this case.
Finally, it is also possible to overwrite the default source lookup by specifying source folders or archives in the source tab of the launch configuration. But you should normally not need to do this, when your build path is configured correctly. From the Eclipse Help:
The Source tab defines the location of source files used to display source when debugging a Java application. By default, these settings are derived from the associated project's build path. You may override these settings here.
I had this very annoying problem for a long time but was finally able to solve it. In my case, a null pointer exception was being thrown somewhere in Java's Transformer.IsRuntimeCode(ProtectionDomain) function.
I didn't really need to know about this since the exception was being caught and handled, but eclipse would pause debugging every time this happened and tell me that the source wasn't available. As a result, I constantly had to keep pressing the button to continue code execution.
In order to prevent this from happening, I:
1. Clicked on the "Breakpoints" window at the bottom of the debugging
screen
2. Right clicked "NullPointerException"
3. Unchecked "Caught"
This prevented the debugger from pausing program flow during a caught NullPointerException.alt text
(source: SharpDetail.com)
And this another one as:
Eclipse doesn't crash. You're trying to step into a method, where eclipse doesn't know where to find the source (*.java) files and informs you about this. Here is how to tell eclipse where to look. Go to
Window->Preferences->Java->Installed JREs,select the JRE you are using and click Edit.
There, select all of the jar files in the list you see and and click Source Attachment....
In the window that shows up, select the fille src.zip, which is in your JDK folder (if you didn't uncheck it while installing the JDK). On the machine I'm on right now, that is
C:\Program Files\Java\jdk1.7.0_07\src.zip.
Save all your changes (possibly restart eclipse) and you won't see that error again.
Well it turns out the solution was anticlimactic. When Balder's recommendations did not work I tried debugging one of the stock OpenFire plugins and it worked just fine. I then created a new plugin from scratch, and by doing nothing other than adding the source to the project (Right-click on the project -> New -> Source Folder) it also worked just fine. I have no idea why Eclipse refuses to see the source for my original plugin, but I moved all my code and libraries over to the new plugin and debugging is working as expected.
Many times you put jar files in eclipse IDE as referenced libraries when binary version of application was downloaded. Usually done so by configuring the build path. But the binary does not have the source files. You have Binary version and source version of application.
One simple way is to download the source libraries that you also use maven to build the project.
Keep somehwere, may be inside your project workspace.
Now while seeing the class file (from eclipse, jar exploded) you may see the source not found, fine.... there is a button below and click on that, a new window opens and there select add external folder.
Reference it to the src folder of the source you downloaded(not the binary one) and kept somewhere as said above and it will show the class details from that.
I fixed this issue with doing the following:
Click at the menu Window - Preferences - Debug - Step Filtering And check all the packages like the following image.
(Step Filtering)
Then, debug again your project and thats it.
Best regards,
In my case, I had a breakpoint in the class declaration. I mean in the next line.
public class GenerateInterface implements JavaCall {
So, the debugger stopped in that line and showed the following message:
Source not found
I think unconsciously activate the breakpoint in that line.
I have one jar file. I want to see the source code of classes of this jar file and i need to use source code of this jar file. Is there any option to view and use that jar file source code?
Is there any option in eclipse to extract jar file and to see the source code of that jar file?
if you add a jar as dependency to your project, you can also link sourcecode to it.
Rightclick on project->Build Path->Configure Buildpath. There, choose the jar that you linked into your project, extend it and under "source attachments", you can add the jar that contains the sources of this specific jar
You can add the JAR file with the byte code and attach the source JAR as well. You can't do without the first; the second is optional.
It's easy to do in IntelliJ; I'm not sure about the steps in Eclipse.
Right click on Your procjet. Chose properties.
Select Libraries
Chose Your jar
Profit
The JAR file you are refering too may not have source code attached.
Usually, when downloading third party library you can download JARs with byte-code and source code separetredly. The best way to check is to simply extract JAR file (with ZIP extracting tool) and check whether you have source there. If so, you can do the following:
1. Add the JAR to your Eclipse project (just drag it there and choose whether you want to copy or link to the JAR).
2. Whenever you are opening class file that does not come with source-code and you are shown "Source not found" page - just press button "Attach Source.." and find your JAR file with source code.
[EDIT] use JD-GUI to extract source code (*.java files) from *.class files contained in JAR file.
In my case I had in Java Build Path Source attachment with meaningful path (not NONE), but file itself was absent in this place. I configure project to Maven nature. And then from Maven make Download sources - file -source.jar appears.
Yes,You can see the source code of all the files those are added in your jar file.first you have to add jar file same as shown by the Marcin Szymczak. and after that click on "Referenced library". After that click on Your jar.and you can check all the classes source code.In my case jar file-Hackerrank.jar and you can see source code of classes:
This applies to plugin jars (if that is your case):
Ensure to put the jar into your target platform folder
Refresh your target platform: Window -> Preferences -> Target Platform -> Select your current target -> Edit -> Finish -> Reload -> Ok
Open the "Plug-ins" view: Window -> Show view -> Plug-ins
In that view, locate the new plugin jar: right click and Import As -> Source Project.
You will have it as a plugin project in your workspace.
I would like to have the javadoc comments contained in a jar file show in eclipse when I hover over a class.
For example, after downloading JODA-2.0, three jars are obtained:
joda-time-2.0
joda-time-2.0-javadoc
joda-time-2.0-sources
(http://sourceforge.net/projects/joda-time/files/joda-time/2.0/joda-time-2.0-dist.zip/download)
In eclipse, [right click project -> Properties -> Java Build Path -> Libraries -> ADD JARs...] includes the binary in the project (can reference those classes) for joda-time-2.0.jar.
But how can I link in the sources/javadoc comments contained in the other two jar files so that when I hover over those classes I see the javadocs?
Adding the other two jars (joda-time-2.0-javadoc.jar and joda-time-2.0-sources.jar) to the build path does not link the javadocs or the source.
Right click over the project -> Build path -> Configure build path
In the new window, go to the "Libraries" tab.
Select the library and expand it.
There are 4 child options. Select "Javadoc location" and click the "Edit" button on the right.
Now you can add a jar file containing the docs. This would be just a zip file with the extension changed to jar. Make sure inside the jar the index.html is in the root. You can press the "Validate" button to check everything is ok.
You can try to CTRL + click on a class that has no source attached (do that in editor). When it shows you some info about the class you'll see the button that guides to attach source dialog. Click it and in dialog that pops up pick the source/javadoc location for your class.
You can also do that from project build path settings you are mentioning: pick libraries tab, expand the library (jar) you want and you'll be offered to pick: source attachment, javadoc attachment, native library location, etc. You just pick whatever you want and edit its current settings.
Or you can do as #JB Nizet said...
Right-click on the jar (the one with the class files), choose "Properties", the "Javadoc location", and choose the jar file with the javadoc. Do similarly for the source jar, using "Java source attachment".
You can also edit the classpathentry in the file ".classpath" in your eclipse project. This can be helpful if you want to modify many entries at once or if you want to generate the path.
e.g.:
<classpathentry kind="var" path="HOME/3rdparty/junit.jar" sourcepath="/SOURCE/junit_src.zip"/>
The easiest way is :
Press control+(The word for which you want to see the Java doc)
A page will appear that has a button for attach source.Click This
Select External location.
Browse The location to Java folder than your jdk .Than select
src .zip.
press OK.
The Problem is Solved.