英文:
MavenReportException: JAVA_HOME not correctly set
问题
我尝试了许多JDK版本,希望能解决这个问题,但无论我使用哪个Java版本,结果都是一样的。
> MavenReportException:创建归档时出错:找不到javadoc命令:环境变量JAVA_HOME设置不正确。
调试
我运行了:
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
mvn clean deploy -P release
> MavenReportException:创建归档时出错:找不到javadoc命令:环境变量JAVA_HOME设置不正确。
Maven插件配置
<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>
尽管which java
和which javadoc
指向/usr/bin
,但可能是问题所在吗?
编辑 1
/bin
的内容
英文:
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.
Debug
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
mvn clean deploy -P release
> MavenReportException: Error while creating archive: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set.
Maven Plugin Configuration
<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?
Edit 1
Contents of /bin
答案1
得分: 6
以下是翻译好的内容:
我不知道这是否有所帮助,但在我的情况下,Maven出现了问题:
Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:jar
并且产生了异常:
MavenReportException: 生成Javadoc时出错:无法找到javadoc命令:JAVA_HOME环境变量未正确设置。
解决方案是找到导致问题的插件,
在我这里是 <artifactId>maven-javadoc-plugin</artifactId>
,并添加以下内容:
<configuration>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
</configuration>
其中${java.home}
是 /usr/lib/jvm/java-11-openjdk-amd64/
。
插件的配置如下:
<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>
并且目标成功执行。
英文:
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.
答案2
得分: 0
请使用以下命令检查Maven的Java版本:
#mvn --version
它会显示类似以下内容:
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
在这里,您可以看到使用的JAVA版本及其位置。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论