Unable to find javadoc command - maven

本小妞迷上赌 提交于 2019-11-29 11:16:54

问题


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

mvn clean javadoc:jar package

I do have my JAVA_HOME variable set correctly. Evidently:

$ which java
/usr/bin/java
$ sudo ls -l /usr/bin/java
lrwxr-xr-x  1 root  wheel  74 Dec 18 23:42 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

$ which javadoc
/usr/bin/javadoc

Does anyone know why mvn still complains?

Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.8:jar (default-cli) on project foo_bar: MavenReportException: Error while creating archive: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set. -> [Help 1]

回答1:


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



回答2:


You can make it use the java.home system property instead of the JAVA_HOME environment variable:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
                </configuration>
            </plugin>

Source of idea: https://medium.com/@kankvish/fixing-issue-the-environment-variable-java-home-is-not-correctly-set-b5f0b66a84d0




回答3:


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!




回答4:


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.




回答5:


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.



来源:https://stackoverflow.com/questions/13961615/unable-to-find-javadoc-command-maven

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!