31

Suppose I have project directory MyProject, under which I have src directory with sources of the program.

I want to compile all javadocs from there. What is the simplest command to issue?

If I run

javadoc -sourcepath ./src -d ./docs

I get an error

javadoc: error - No packages or classes specified.

Can't it deduce packages from source files?

EDIT 1

This way also causes an error

...MyProject>javadoc -sourcepath ./src *.java -d ./docs
Creating destination directory: "./docs\"
javadoc: error - File not found: "*.java"
1 error
Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385

6 Answers6

23

The following worked for me

javadoc -sourcepath ./src -d ./docs -subpackages .
Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385
11

The man page says it will only explicitly document packages that it is given. There is an option called subpackages that recursively documents the given package and all it subpackages, but you must still specify all base packages.

eg.

javadoc -d /home/html -sourcepath /home/src -subpackages java -exclude java.net:java.lang

http://www.manpagez.com/man/1/javadoc/

Dunes
  • 37,291
  • 7
  • 81
  • 97
10

In linux, it worked for me when I did the following

javadoc -d docs/ $(find . -name *.java)

I hope this helps

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
kholofelo Maloma
  • 973
  • 3
  • 15
  • 26
  • 1
    Worked for me! I had to add a . to the find command: `find . -name *.java`. – Mike Jeffrey Aug 18 '16 at 19:01
  • How about generating the javadocs within a project with multiple directories and packages not within the root path? My find command can find it, but I receive X number of errors depending on the number of X source files. – Joyoyoyoyoyo Aug 30 '18 at 17:49
3

try using javadoc -sourcepath ./src *.java -d ./docs

Rahul Borkar
  • 2,742
  • 3
  • 24
  • 38
3

The lazy way is to use Eclipse : Project --> GenerateJavadoc and choose the package/project you want to document.

cl-r
  • 1,264
  • 1
  • 12
  • 26
0

For me also the following worked:

javadoc -sourcepath ./src **/*.java -d ./docs
derwiwie
  • 875
  • 10
  • 16