I am using JDK 11 on Apache netbeans 10.
The main
method is depricated since java 9 and marked for a removal where there is no alternative
All of my attempts in command line ended up with
javadoc: error - Cannot find doclet class Exception
When I try:
com.sun.tools.javadoc.Main.execute (new String[]{"-doclet",TestVarElement.class.getName(),"C:\\Users\\Super3\\Documents\\NetBeansProjects\\MyProject\\src\\pk\\TestVarElement.java"});
I get:
javadoc: error - Doclet class pk.TestVarElement does not contain a start method
Start
method is depricated and replaced by run
method, the previous set up is working for java 8 and older, I want the equivalent for 9,10,11.
I looked at the documentation for DocumentationTool and the relevent materials but I did not find a single working example.
Is there any way we can run a Doclet/DocletEnvironment programmatically or a working example from commandline?
Assuming what you're trying to do is run Javadoc programatically, the
jdk.javadoc
module documentation describes ways to do so:Based on your previous code, and your edit, you don't need the functionality of the
DocumentationTool
SPI. TheToolProvider
SPI should suffice. As mentioned in the documentation (and by @AlanBateman in the comments) you can get theToolProvider
instance using the following:You then call one of the
run
methods with the out/err streams of your choice and the desired arguments. The arguments are the same you'd use for the unsupportedMain.execute
API you're currently using.