This week's book giveaway is in the HTML, CSS and JavaScript forum.
We're giving away four copies of hapi.js in Action and have Matt Harrison on-line!
See this thread for details.
Win a copy of hapi.js in Action this week in the HTML, CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do use javadoc to look in all package directories

 
Richard Hayward
Ranch Hand
Posts: 124
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have folder structures like this:


Working in a command window in the src directory (I'm on xp), I can use javadoc to produce documentation for source files sitting directly in the src folder

src>javadoc  -d ../docs  *.java

but I can't see how to tell javadoc to look in all packages. I've been experimenting with things like

src>javadoc -d ../docs -subpackages *.java

but can't get it to work. I have hundreds of packages, so explicitly listing them on the command line isn't practical.

Could anyone tell me what the correct syntax is?
I'm hoping to end up with javadoc producing an index.html with frames, where I can browse to the package to look at, just like the api docs.
 
Knute Snortum
Sheriff
Posts: 3124
79
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you ever used Maven?  It has a great plugin that does all your Javadoc building.  If you have never used Maven then it's probably overkill.
 
Knute Snortum
Sheriff
Posts: 3124
79
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you on a Unix-like OS?  Then try:

find . -type f -name "*.java" | xargs javadoc -d outputdir
 
Knute Snortum
Sheriff
Posts: 3124
79
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ooo, even better!

javadoc -sourcepath src\main\java -d docs -subpackages .

Notice the dot at the end.
 
Knute Snortum
Sheriff
Posts: 3124
79
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and one more, IDEs, like Eclipse, will let you generate Javadocs.

Eclipse: Project -> Generate Javadocs...
IDEA: Tools -> Generate JavaDocs...
 
Richard Hayward
Ranch Hand
Posts: 124
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Knute,
Knute Snortum wrote:Have you ever used Maven?

No. I did mess with it a while back but found it an incomprehensible and unpleasant experience
I'd rather learn how the basic tools work before adding on another layer of complexity. 
Knute Snortum wrote:Are you on a Unix-like OS?

No, as I mentioned, I'm using xp.
Knute Snortum wrote:Ooo, even better!
javadoc -sourcepath src\main\java -d docs -subpackages .
Notice the dot at the end.

This is the kind of thing I'm looking for! Adjusting, hopefully correctly,  to my directory structure:

src>javadoc -d ..\docs -sourcepath .\ -subpackages .

I get hundreds of errors. Looking at those errors, javadoc seems to be looking at files completely outside of the src directory I've started it from, and which I thought I was specifying via -sourcepath .\

Also. many errors relate to illegal characters in .class files. I do indeed have a few class files in my src folders, but from reading
http://download.java.net/jdk7u2/docs/technotes/tools/solaris/javadoc.html#processingofsourcefiles
I'd thought javadoc only concerns itself with .java files.

 
Knute Snortum
Sheriff
Posts: 3124
79
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't use -sourcepath .\, just -sourcepath . (no backslash).

javadoc will look at any type of file.  You could try putting "*.java" at the end of the command, but I don't know if that will work in XP. 

The way I have my folders setup, I can specify src/main/java and javadoc will only see my source files, excluding test files.  Also, all my .class files are in "target" outside the src folder.



 
Knute Snortum
Sheriff
Posts: 3124
79
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a more up-to-date document on javadoc:

https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html
 
Richard Hayward
Ranch Hand
Posts: 124
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help Knute.

I've realized that what I was assuming I could do, generate documentation for all packages in a single invocation of javadoc was impractical.
Several packages have code that I know won't compile, I was experimenting with various features of the language.

I've decided to maintain a javadoc.config file:

to which I can add packages, as I work on them.

Then, just periodically invoke
>javadoc @javadoc.config

Seems best for they way I work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!