0

I have a doclet that prints the class data. I run the file from command line and it works fine. But, I want to run it within a java program also. So, I used the below main method in my doclet:

public class SimpleDoclet extends Doclet {

public static void main(String[] args) {
    System.out.println("====Starting the doclet=====");
    String[] args1 = { "javadoc -private -doclet "
            + SimpleDoclet.class.getName()
            + " -classpath /usr/java/jdk1.6.0_30/lib/tools.jar newPack/NewClass.java" };
    com.sun.tools.javadoc.Main.execute(args1);
}

NewClass.java is the java file that I want SimpleDoclet to generate javadoc. Can I do this?

If so, then when I run this doclet, I get this error message:

====Starting the doclet=====
javadoc: error - File not found: "javadoc -private -doclet oldPack.SimpleDoclet -classpath /usr/java/jdk1.6.0_30/lib/tools.jar newPack/NewClass.java"
1 error

Any solutions please?

Mercenary
  • 2,106
  • 6
  • 34
  • 43

1 Answers1

0

You are specifying a single argument where you should be specifying several.

{"javadoc", "-private", ...}
user207421
  • 305,947
  • 44
  • 307
  • 483
  • Thanks!! After a long try, I got it working for a single file... `com.sun.tools.javadoc.Main.execute(new String[] { "-doclet", "package.DocIt", "-docletpath", "", "-private", "/Example.java"});` but I need to run it for multiple files!! I tried changing the last argument to `*.java` but it said file not found! – Mercenary Feb 12 '13 at 12:35