Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

macos - Unable to find javadoc command - maven

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]
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...