Unable to find javadoc command - maven

后端 未结 7 472
南笙
南笙 2020-12-30 20:56

I ran this command in my project directory to build and package it:

mvn clean javadoc:jar package

I do have my JAVA_HOME varia

相关标签:
7条回答
  • 2020-12-30 21:07

    After spending 2-3 hours of time, i felt opening Eclipse via command line looks easiest solution. Follow below steps,

    cd <Folder_where_Eclipse.app> open Eclipse.app

    Now your eclipse can able to find the Terminal Environmental variables.

    0 讨论(0)
  • 2020-12-30 21:15

    While a lot of answers talk about OS X, for a Debian or Debian-like system (such as Ubuntu), I've decided to abuse the "alternatives" system:

    export JAVA_HOME=$(update-alternatives --query javadoc | grep Value: | head -n1 | sed 's/Value: //' | sed 's@bin/javadoc$@@')
    

    Rewriting that more cleanly with awk, or using a more correct way to access the value in the "alternatives" database, is left as an exercise for the reader.

    Alternatively, given that the point of using "alternatives" system is to maintain symlinks such as /usr/bin/javadoc in this case, we can just query the path pointed to by the symlink:

    export JAVA_HOME=$(realpath /usr/bin/javadoc | sed 's@bin/javadoc$@@')
    

    While this isn't the only possible "Java home" (you might have numerous JDKs installed), given that I only care about moving the mvn build forward, and the error talks about Javadoc, I chose to refer to this the directory containing the javadoc binary.


    Don't forget to install a JDK in addition to a JRE. For instance, the JDK I needed was openjdk-11-jdk, to complement the JRE openjdk-11-jre which I previously installed.


    After the above, the JAVA_HOME envvar has this value on my system: /usr/lib/jvm/java-11-openjdk-amd64/

    0 讨论(0)
  • 2020-12-30 21:17

    A correct which java is not evidence enough, since /usr/bin/ will likely be in your PATH anyway. Check

    $ echo $JAVA_HOME
    

    for evidence. Or run

    $ JAVA_HOME=/path/to/your/java/home mvn clean javadoc:jar package
    

    On OS X you can set your JAVA_HOME via:

    $ export JAVA_HOME=$(/usr/libexec/java_home)
    

    which on my machine points to

    /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    
    0 讨论(0)
  • 2020-12-30 21:18

    You can add the JAVA_HOME as an environment variable in eclipse.

    Go to your maven build-> add the following.

    Click New->

    Name: JAVA_HOME

    Value : your path here.

    This worked for me!

    0 讨论(0)
  • 2020-12-30 21:22

    They fixed this for OSX in maven 3.1 by adding "export JAVA_HOME" to the "bin/mvn" shell script, obviating the need to set JAVA_HOME externally yourself just to find javadoc.

    0 讨论(0)
  • 2020-12-30 21:24

    There are 2 options to fix this. Here are the steps:

    1. Make sure to configure JAVA_HOME as an environment variable.

    2. Option 1: Add javadocExecutable into properties.

      <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          <project.reporting.outputEncoding>${project.build.sourceEncoding
          </project.reporting.outputEncoding>
          <java.version>11</java.version>
          <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
      </properties>
      
    3. Option 2: Add javadocExecutable into the build section as below.

      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>${maven-javadoc-plugin.version}</version>
          <executions>
              <execution>
                  <id>attach-javadocs</id>
                  <goals>
                      <goal>jar</goal>
                  </goals>
                  <configuration>
                      <additionalparam>-Xdoclint:none</additionalparam>
                  </configuration>
              </execution>
          </executions>
          <configuration>
              <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
              <excludePackageNames>com.vu.poc.test.objects</excludePackageNames>
              <overview />
          </configuration>
      </plugin>
      
    0 讨论(0)
提交回复
热议问题