开发者

javadoc: how to use it to document ONE single java file on Window 7?

I'm trying to use javadoc to document one single java file on window 7,to simplify things, I only use the following simple command:

javadoc Attr.java

However, javadoc gives me IllegalArgumentException without detailed where it is wrong, actually, the file I used is copied from The Java Programming. So, I'm wondering what is required to use "javadoc" comand in the window environement.

It seems to be working at first ...

Loading source file Attr.java...
Constructing Javadoc information...
Standard Doclet version 1.6.0_20
Building tree for all the packages and classes...
Generating Attr.html...

But then it starts throwing errors like this:

java.lang.IllegalArgumentException
        at sun.net.www.ParseUtil.decode(ParseUtil.java:189)
        at sun.misc.URLClassPath$FileLoader.<init>(URLClassPath.java:958)
        at sun.misc.URLClassPath$3.run(URLClassPath.java:328)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.misc.URLClassPath.getLoader(URLClassPath.java:322)
        at sun.misc.URLClassPath.getLoader(URLClassPath.java:299)
        at sun.misc.URLClassPath.findResource(URLClassPath.java:145)
        at java.net.URLClassLoader$2.run(URLClassLoader.java:385)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findResource(URLClassLoader.java:382)
        at java.lang.ClassLoader.getResource(ClassLoader.java:1003)
        at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:1193)
        at javax.xml.parsers.SecuritySupport$4.run(SecuritySupport.java:96)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.xml.parsers.SecuritySupport.getResourceAsStream(SecuritySupport.java:89)
      开发者_JAVA百科  at javax.xml.parsers.FactoryFinder.findJarServiceProvider(FactoryFinder.java:250)
        at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:223)
        at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:128)

Here is the java test file I used:

/**
 * An <code>Attr</code> object defines an attribute as a
 * name/value pair, where the name is a <code>String</code>
 * and the value an arbitrary <code>Object</code>.
 *
 * @version 1.1
 * @author Plato
 * @since 1.0
 */
public class Attr {
    /** The attribute name. */
    private final String name;
    /** The attribute value. */
    private Object value = null;

    /**
     * Creates a new attribute with the given name and an
     * initial value of <code>null</code>.
     * @see Attr#Attr(String,Object)
     */
    public Attr(String name) {
        this.name = name;
    }

    /**
     * Creates a new attribute with the given name and
     * initial value.
     * @see Attr#Attr(String)
     */
    public Attr(String name, Object value) {
        this.name = name;
        this.value = value;
    }

    /** Returns this attribute's name. */
    public String getName() {
        return name;
    }

    /** Returns this attribute's value. */
    public Object getValue() {
        return value;
    }

    /**
     * Sets the value of this attribute.  Changes the
     * value returned by calls to {@link #getValue}.
     * @param newValue  The new value for the attribute.
     * @return  The original value.
     * @see #getValue()
     */
    public Object setValue(Object newValue) {
        Object oldVal = value;
        value = newValue;
        return oldVal;
    }

    /**
     * Returns a string of the form <code>name=value</code>.
     */
    public String toString() {
        return name + "='" + value + "'";
    }
}

/===== SOLUTIONS - Thanks to Michael Borgwardt =========/

first issue:

set CLASSPATH=. 

then

javadoc Attr.java


Hm... considering that the error happens in a ParseUtil called by the URLClassLoader: is it possible that you have a CLASSPATH environment variable set whose content is malformed? Try this:

javadoc -classpath . Attr.java


Make sure that your working directory is the same as the directory containing Attr.java. The command should work as stated then.


You can also try :-

javadoc <yourAbsPathToJavaFile>.java

It had worked for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜