How do I run Javadoc from within a Java application?
For Javadoc 1.2 and later: your_method() { // your code String[] javadocargs = { “-sourcepath”, “/home/atuld/JDK/1.3/src/share/classes”, “-nodeprecated”, “-d”, “applet”, “java.applet” }; com.sun.tools.javadoc.Main.main(javadocargs); // your code } The disadvantages of this are: (1) It can only be called once per run (since static information is stored) – use java.lang.Runtime.exec(“javadoc …”) if more than one call is needed. (2) Exit code is not returned, so you can’t tell if it failed. (3) Can’t set where output goes or what the command is called. For Javadoc 1.1.x, drop com (above) and instead use sun.tools.javadoc.Main.main(javadocargs);. In the next major verion of Javadoc after 1.3 (probably to be called 1.4), we will be releasing a programmable interface for this in the form of an execute method. See Request 4113483.