Reputation: 1499
I've tried many JDK versions in order to solve this problem but it seems no matter which java i'm using the outcome is always the same.
MavenReportException: Error while creating archive: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set.
These are the jdk's currently installed:
I ran :
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
java -version
:
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (build 1.8.0_265-8u265-b01-0ubuntu2~20.04-b01)
OpenJDK 64-Bit Server VM (build 25.265-b01, mixed mode)
javac -version
javac 1.8.0_265
MavenReportException: Error while creating archive: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<executable>${JAVA_HOME}/bin/javac</executable>
</configuration>
</plugin>
Although which java
and which javadoc
pointing to /usr/bin
could that be the issue?
Contents of /bin
Upvotes: 6
Views: 16553
Reputation: 1060
I don't know if this helps, but in my case maven
Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:jar
and gave an exception:
MavenReportException: Error while generating Javadoc: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set.
The solution was to find the plugin that was causing the issue,
<artifactId>maven-javadoc-plugin</artifactId>
in my case and add the following:
<configuration>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
</configuration>
where ${java.home}
was /usr/lib/jvm/java-11-openjdk-amd64/
.
The plugin looked like:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
</configuration>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
and the goal was executed successfully.
Upvotes: 6
Reputation: 39
Please check the java version for Maven using the following command:
#mvn --version
It will give something like:
Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-25T01:19:05+05:30) Maven home: /home/user/apache-maven-3.5.3 Java version: 1.8.0_121, vendor: Oracle Corporation Java home: /home/user/jdk1.8.0_121/jre Default locale: en_IN, platform encoding: UTF-8
Here, you can see which JAVA version is used and its location.
Upvotes: 1