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.
Related
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 have web application that is running in Jboss container.
Sometime I need to debug the code and for the I need to know from which jar current class is being referred (so that i could search of source jar of the corresponding jar)
Is it possible to get this Jar information (name of the jar file) from which current class is being referred. See the attached screen shot - from where i am trying to get this jar file information. Not sure if my approach is right or wrong
Eclipse allows you to make code changes during debug time.
So, if you want to entering in a class and know what is the jar source of this class just do CTRL + Mouse Right click in the class name and you enter inside the class.
If you have the "Link with Editor" option selected in your Package Explorer you can see automaticly what is ths jar file you are importing.
Compile time classpath settings are different from Runtime server classpath settings.
So if you want to know all the locations/jars that contain a particular class at compile time in eclipse then use Ctrl+T and type the class name. If there are multiple jar files with same class/namespace, then the order will be defined in Build Path settings --> Order and Export.
Runtime reference depends on class loading policy of your server configuration. But usually first it refers from local project, then manifest and then from common class path library.
If your server is configured to refer the workspace location of your project, then most probably the order would be as you defined in .classpath file, and you can use Ctrl+T to find it out.
Edit
It seems you want eclipse to resolve the source file automatically. If you are using maven then run below commands to refresh the source and javadoc for all your jar files.
mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc
I use eclipse.
my problem description:
In import I see red underlyed strings. But if I navigate - I see source code.
How does it dispay?
How can I fix it?
You must adjust the project's build path, so it contains the missing packages.
Long answer
You may navigate every class that is known to the workspace. But if they are underlined it means they are not available when building the project.
Click on the node "Referenced Libraries" to see what's included. If your imported package JAR is not listed there, adjust the build path.
Right-click on the folder containing "com/epam/dentsply/service" and choose "Build Path/Use as Source Folder". Be sure to select the one directly containing the "com" directory with your java files.
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:
I'm running Eclipse 3.5.2 and am debugging a class which calls a method -- let's call it flaky() -- in one of my other .jar files. When I step into flaky(), it shows the source code in a tab in the debugger, with the filename as Flaky.class.
The problem is, the code I see looks old and out of date, so I'm wondering which file I'm looking at.
Is there any way to find out the path of the file Eclipse is displaying?
Go to the Package Explorer view with the file open in the current editor. Click the "Link with Editor" toggle (the two arrows). This should jump you to the class file you are viewing, which should be in the jar you are using. If the jar is in a library, you should see the path to the jar in the package explorer. If not you can see the path to it in the preferences. From there you can also use Chin Huang's answer to find where the given source file is.
View the Properties for the JAR file. Under Java Source Attachment, you will see where Eclipse gets the source code for classes in the JAR file.