Search code examples
eclipsejavadoceclipse-mars

Unable to generate javadoc in Eclipse for linked source files


I am unable to generate javadoc for linked .java files using Eclipse Mars.

This shows how my project is set up: Eclipse view

I am able to run the program.

The source file is in a folder named foo, to match the package declaration:

Directory Ellen > Google Drive > 64 2016 > src > foo

I select Project > Generate Javadoc... and check the package:

enter image description here

I agree to all of the default options.

I get this output in the console:

Loading source files for package foo...
Constructing Javadoc information...
javadoc: warning - No source files for package foo
javadoc: warning - No source files for package foo
javadoc: error - No public or protected classes found to document.
1 error
2 warnings

Adding javadoc comments to the source code makes no difference.

I have no trouble generating javadoc when I do not have linked source files.

How do I set up links to source files so I can generate javadoc?


Solution

  • When you do Project > Generate Javadoc... it launches the external program javadoc part of the JDK typically. The javadoc program does not understand/know about Eclipse linked resources, so it sees the empty folder.

    How do I set up links to source files so I can generate javadoc?

    Short answer is you cannot with links at the file level.

    Use Links to src folder

    Rather than doing a link to files within a package, make the link to the containing source folder. In your screenshot you don't have a src folder, but you could create one that is linked.

    For example, I have a project called demoforso, in it I create a folder called src that is linked to D:\tmp\src and add src to classpath. When the javadoc is run on this project, it passes D:\tmp\src as the sourcepath.

    Use Javadoc views in Eclipse

    (i.e. Don't generate Javadoc at all, granted possibly not useful in your case, but included for completeness.)

    The hovers and Javadoc view in Eclipse means that you never need to generated Javadoc for your own use.