Can anybody show me how to generate Javadoc from command line?
My project contains the package com.test
and I want to put the generated documentation in files located in a specific folder like this: C:/javadoc/test
.
The javadoc command parses the declarations and documentation comments in a set of Java source files and produces a corresponding set of HTML pages that describe (by default) the public and protected classes, nested classes (but not anonymous inner classes), interfaces, constructors, methods, and fields.
Choose Tools > Java Platform Manager from the main window. Select the platform to which you want to add Javadoc in the left panel of the dialog box. In the Javadoc tab, click Add ZIP/Folder and specify the location of the Javadoc files. Click Close.
You can refer the javadoc 8 documentation
I think what you are looking at is something like this:
javadoc -d C:\javadoc\test com.test
Oracle provides some simple examples:
http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#CHDJBGFC
Assuming you are in ~/ and the java source tree is in ./saxon_source/net and you want to recurse through the whole source tree net is both a directory and the top package name.
mkdir saxon_docs
javadoc -d saxon_docs -sourcepath saxon_source -subpackages net
Let's say you have the following directory structure where you want to generate javadocs on file1.java
and file2.java
(package com.test), with the javadocs being placed in C:\javadoc\test
:
C:\
|
+--javadoc\
| |
| +--test\
|
+--projects\
|
+--com\
|
+--test\
|
+--file1.java
+--file2.java
In the command terminal, navigate to the root of your package: C:\projects
. If you just want to generate the standard javadocs on all the java files inside the project, run the following command (for multiple packages, separate the package names by spaces):
C:\projects> javadoc -d [path to javadoc destination directory] [package name]
C:\projects> javadoc -d C:\javadoc\test com.test
If you want to run javadocs from elsewhere, you'll need to specify the sourcepath. For example, if you were to run javadocs in in C:\
, you would modify the command as such:
C:\> javadoc -d [path to javadoc destination directory] -sourcepath [path to package directory] [package name]
C:\> javadoc -d C:\javadoc\test -sourcepath C:\projects com.test
If you want to run javadocs on only selected .java files, then add the source filenames separated by spaces (you can use an asterisk (*) for a wildcard). Make sure to include the path to the files:
C:\> javadoc -d [path to javadoc destination directory] [source filenames]
C:\> javadoc -d C:\javadoc\test C:\projects\com\test\file1.java
More information/scenarios can be found here.
For example if I had an application source code structure that looked like this:
Then I would do:
javadoc -d "C:\docs" -sourcepath "C:\b2b" -subpackages com
And that should create javadocs for source code of the com package, and all subpackages (recursively), found inside the "C:\b2b" directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With