Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Maven javadoc fail with error "cannot read options"?

When I run mvn javadoc:javadoc, I get the following error:

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] An error has occurred in JavaDocs report generation:Exit code: 1 -
javadoc: error - cannot read options (The system cannot find the file specified)

Command line was:"C:\Program Files\Java\jdk1.6.0_14\jre\..\bin\javadoc.exe"
 @options @packages

When I invoke the command "C:\Program Files\Java\jdk1.6.0_14\jre..\bin\javadoc.exe" on my system it runs the javadoc executable.

I am running:

  • JDK 1.6.0_14
  • Maven 2.0.8

The javadoc reporting part of my POM looks like:

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
      </plugin>
      ...

And relevant environment variables:

JAVA_HOME=C:\Program Files\Java\jdk1.6.0_14
M2_HOME=C:\Program Files\Apache Software Foundation\apache-maven-2.0.8
M2_REPO=C:\Documents and Settings\<user>\.m2\repository //<user> is my user
MAVEN_OPTS=-XX:MaxPermSize=128m -Xmx512m

I have tried reinstalling Java and Maven, as well as using Maven 2.1.0, JDK 1.6.0_11, and even JDK 1.5.0_11. I have compared my setup to a coworker who has practically the same environment but no problems. It used to work about a month ago, and no, I don't know what's changed on my system since then. I first encountered it with JDK 1.6.0_11. This happens on every project I've tried in our repository, and my coworkers have no problems with the same projects. So I'm pretty sure it's just my environment and not the projects themselves.

I would really appreciate any suggestions on this.

like image 496
dave4351 Avatar asked Jun 23 '09 18:06

dave4351


People also ask

How do I fix javadoc errors?

You need to call mvn javadoc:fix to fix main Java source files (i.e. inside src/main/java directory) or mvn javadoc:test-fix to fix test Java source files (i.e. inside src/test/java directory).

What is Maven javadoc plugin?

The Javadoc Plugin uses the Javadoc tool to generate javadocs for the specified project. For more information about the standard Javadoc tool, please refer to Reference Guide. The Javadoc Plugin gets the parameter values that will be used from the plugin configuration specified in the pom.

How do I publish a javadoc?

In the Goals field, place javadoc:javadoc —this will tell Maven to generate the Javadoc documentation. Now go to the “Post-build Action” and tick the “Publish Javadoc” checkbox. This project is a multimodule project, so a separate subdirectory is generated for each module (core, services, web and so forth).


1 Answers

I figured it out, but first I tried various things:

  • Uninstalling every JDK and JRE on my system, and then reinstalling Java to a path with no spaces
  • Removing every environment variable I wasn't using, and cleaning up my PATH
  • Relocating Maven and my local repo to directories with no spaces
  • Rebooting (you never know, it's Windows)

Today I tried to run a batch file which didn't execute properly, and I quickly realized that when I double clicked on it, it was executing the file but not in the directory where it lived. And then it hit me.

A few weeks ago I got fed up with our IT guys forcing our cmd window to open at H: and so I Googled and used this page to "fix it". It seemed to work; I didn't have any problems for a few weeks and I had already forgotten that my cmd windows all used to open to some H: drive. But every single cmd window opened to a directory I specified--whether I ran "cmd" or clicked a batch file or if Maven opened a new cmd window...

I guess when Maven runs it shells out to execute the javadoc command. And so the javadoc part was working, but it couldn't find the options file it writes out because the working directory was wrong.

So, now I'm back on H: until I can figure that out. And then I'll screw something else up. But hopefully, if nothing else, this will help someone else...

like image 152
dave4351 Avatar answered Oct 22 '22 09:10

dave4351