This discussion is archived
1 2 Previous Next 17 Replies Latest reply: Sep 11, 2009 9:42 AM by 843810 RSS

Javadoc not working from command line

843810 Newbie
Currently Being Moderated
I am not allowed to use an IDE for a SE course I am taking, and I am supposed to write classes using a text editor and test with ant/junit combo. Everything works fine except for javadoc. Whether from the command line - javadoc *.java
or in ant - ant doc
I keep getting this message after it finds my source files:
Standard Doclet version 1.5.0_09
Building tree for all packages and classes...
java.lang.IllegalArgumentException
at sun.net.www.ParseUtil.decode(ParseUtil.java:189)
...continues through many lines ending with
at com.sun.tool.javadoc.Main.main.(Main.java:31)
  • 1. Re: Javadoc not working from command line
    843810 Newbie
    Currently Being Moderated
    Your command is exactly "javadoc *.java"? Do your java sources compile?
    If they do compile, then javadoc should work.
  • 2. Re: Javadoc not working from command line
    843810 Newbie
    Currently Being Moderated
    I've been getting the same problem since switching from release 8 to release 9. After a bunch of my projects failed to recompile, I tried it with a simple test file using the following commandline:

    javadoc -sourcepath src util

    where src is obviously my sourcepath, and util the name of the package. The file I'm trying to javadoc contains the following:

    package .util;

    import java.lang.*;

    public class JavadocTest extends Object
    {
         public void some_method()
         {
              return;
         }
    }

    That's it. Any chance a bug crept into the new release?
  • 3. Re: Javadoc not working from command line
    843810 Newbie
    Currently Being Moderated
    What is the error message you see?
    Is it something like "Package util not found"?

    Don't know if you intended this, bug the package name shown in the source
    file begins with a dot ".util". I don't think that's legal. Try it without the dot.
    BTW, the import statement is not necessary, as java.lang.* is imported by default.

    -Doug
  • 4. Re: Javadoc not working from command line
    843810 Newbie
    Currently Being Moderated
    What is the error message you see?
    Is it something like "Package util not found"?

    Don't know if you intended this, bug the package name
    shown in the source
    file begins with a dot ".util". I don't think that's
    legal. Try it without the dot.
    BTW, the import statement is not necessary, as
    java.lang.* is imported by default.

    -Doug
    Sorry, the .util was just a typo - supposed to be package util. I originally had a longer package name, which I shortened for testing purposes. Still doesn't work. I started a new thread on the subject containing a full printout of the error message et al. Check "Anybody else get IllegalArgumentException after move from jdk1.5r8 to r9?" for full details. In short though, the error message starts with:

    Loading source files for package util...
    Constructing Javadoc information...
    Standard Doclet version 1.5.0_09
    Building tree for all the packages and classes...
    Generating util/\JavadocTest.html...
    java.lang.IllegalArgumentException
    at sun.net.www.ParseUtil.decode(ParseUtil.java:189)


    followed by one hell of a stack trace. The error is definately generated in one of the internal Sun packages though, so I can't go and check it out - no source access.
  • 5. Re: Javadoc not working from command line
    843810 Newbie
    Currently Being Moderated
    I am also having this same problem with a fresh install of J2SE on XP SP2 with all latest updates.

    I did however have javadoc working a few weeks ago but I think it was probably with update 8 not 9.
  • 6. Re: Javadoc not working from command line
    843810 Newbie
    Currently Being Moderated
    I know this isn't exactly a solution (or is it?) but :-

    If you delete your CLASSPATH environmental variable (Windows) or unset your CLASSPATH environmental variable (Linux)

    The damned thing WORKS again.

    NeO
  • 7. Re: Javadoc not working from command line
    843810 Newbie
    Currently Being Moderated
    I know this isn't exactly a solution (or is it?) but
    :-

    If you delete your CLASSPATH environmental variable
    (Windows) or unset your CLASSPATH environmental
    variable (Linux)

    The damned thing WORKS again.

    NeO
    Thanks NeO, works in my setup as well, so at least I can get back to my documentation. Yippee.

    Hope Sun was listening...
  • 8. Re: Javadoc not working from command line
    843810 Newbie
    Currently Being Moderated
    FWIW, Sun recommends NOT using the CLASSPATH environment variable.

    "Using the -classpath option is preferred over setting CLASSPATH environment variable because you can set it individually for each application without affecting other applications and without other applications modifying its value."
    http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/classpath.html

    -Doug
  • 9. Re: Javadoc not working from command line
    843810 Newbie
    Currently Being Moderated
    FWIW, Sun recommends NOT using the CLASSPATH
    environment variable.

    "Using the -classpath option is preferred over
    setting CLASSPATH environment variable because you
    can set it individually for each application without
    affecting other applications and without other
    applications modifying its value."
    http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/c
    lasspath.html

    -Doug
    Good point, but that doesn't change the fact that there's still a bug here somewhere, and that this is only a workaround. The CLASSPATH variable, while not the preferred way of doing things, is still how most of us get to know Java, and what many projects out there rely on. For one of the core JDK tools to react in this way is a significant problem.
  • 10. Re: Javadoc not working from command line
    843810 Newbie
    Currently Being Moderated
    It's not clear to me yet there's a bug in the JDK. What was CLASSPATH set to that caused javadoc not to work?

    Javadoc should work if you set CLASSPATH to the same value you set -classpath to. It might not work if CLASSPATH were set to a value that loaded the wrong classes.

    Or are you saying that javadoc runs that worked in 8 now don't run in 9?

    -Doug
  • 11. Re: Javadoc not working from command line
    843810 Newbie
    Currently Being Moderated
    It's not clear to me yet there's a bug in the JDK.
    What was CLASSPATH set to that caused javadoc not to
    work?

    Javadoc should work if you set CLASSPATH to the same
    value you set -classpath to. It might not work if
    CLASSPATH were set to a value that loaded the wrong
    classes.

    Or are you saying that javadoc runs that worked in 8
    now don't run in 9?

    -Doug
    Exactly that. I did a fresh reinstall between the two versions, but the two installations are identical. The only thing that might be different is the order of class calls in the CLASSPATH, but I doubt that this would have an effect, since the stacktrace reports errors from within the Virtual Machine and, I assume, the core classes. There might have been a conflict on some of my projects, but the test class I described previously on this post should work regardless, since it doesn't reference any external classes save java.lang.

    Anyway, the workaround of disabling the CLASSPATH seems to be working for now, and I'm not going to break my head too much right now, since I have a rather stiff deadline to meet. Hopefully the Silly Season will allow me a bit more time to delve into the issue.
  • 12. Re: Javadoc not working from command line
    843810 Newbie
    Currently Being Moderated
    That's a real change in the code, then. Please submit a bug against this.

    Here's the bug reporting procedure:
    http://java.sun.com/j2se/javadoc/faq/#submitbugs

    -Doug
  • 13. Re: Javadoc not working from command line
    843810 Newbie
    Currently Being Moderated
    Hello,

    this is just to confirm that I was able to solve the same problem by deleting the Windows CLASSPATH. I'm using jdk 1.5.0_06.

    I also checked in the BugDatabase but could not find that this bug has been reported.

    What I found out, however, is that it is not the existence of the CLASSPATH, but rather setting it with SET CLASSPATH=%CLASSPATH%, that causes javadoc to fail.

    If nowbody has submitted or plans to submit this bug, if bug it is, I would be happy to do it.

    Kind regards,

    Psaqualino
  • 14. Re: Javadoc not working from command line
    843810 Newbie
    Currently Being Moderated
    I don't see it in the bug database either. Please submit it.
    Once you post the bug number here, we can all vote to have it fixed.

    -Doug
1 2 Previous Next