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
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.
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/
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
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!
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.
There are 2 options to fix this. Here are the steps:
Make sure to configure JAVA_HOME as an environment variable.
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>
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>