Not able to run a simple doclet program : package

2019-07-07 16:37发布

问题:

I am trying to run a simple doclet program, but I am not able to compile it.

javac -cp /cygdrive/c/Progra~2/Java/jdk1.8.0_65/lib/tools.jar  A.java

But it throws

A.java:1: error: package com.sun.javadoc does not exist import com.sun.javadoc.ClassDoc;

Where A.java is

import com.sun.javadoc.ClassDoc;
public class A {
}

I referred it from

http://download.java.net/jdk7u2/docs/technotes/guides/javadoc/doclet/overview.html

I know that I am doing a simple mistake but I ma not able to figure it out. Can anyone please point me out what am I doing wrong

回答1:

You need to add Tools.jar to the project path. It is not included in the standard installation.

Can I ask why you need com.sun.javadoc? It is in most cases discouraged to use com.sun overall.