Maven报错Please ensure you are using JDK 1.4 or above and not a JRE
Posted dadonggg
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Maven报错Please ensure you are using JDK 1.4 or above and not a JRE相关的知识,希望对你有一定的参考价值。
在部署Jenkins项目时,用Jenkins调用服务器上脚本时,脚本在服务器上执行没有任何问题,但是在Jenkins上调用时就报错,提示mvn应该使用全路径执行,当加入jdk,jre,maven环境变量时,出现下面错误。
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project kpl-model: Compilation failure [ERROR] Unable to locate the Javac Compiler in: [ERROR] /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.x86_64/jre/../lib/tools.jar [ERROR] Please ensure you are using JDK 1.4 or above and [ERROR] not a JRE (the com.sun.tools.javac.Main class is required). [ERROR] In most cases you can change the location of your Java [ERROR] installation by setting the JAVA_HOME environment variable. [ERROR]
而maven编译需要jdk作为运行环境。
因此,我们只要设置为jdk即可,去掉jre环境变量即可。
#!/bin/bash export JAVA_HOME=/usr/local/jdk export M2_HOME=/opt/apache-maven export PATH=$JAVA_HOME/bin:$PATH export PATH=$M2_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
注:使用which java,mvn -v可查询环境变量的家目录
以上是关于Maven报错Please ensure you are using JDK 1.4 or above and not a JRE的主要内容,如果未能解决你的问题,请参考以下文章
IntelliJ IDEA 更新到2020 Cannot load a JDK class: com.sun.jdi.Field Please ensure you run the IDE on
Matlab解决使用Mex 报错There was a problem creating the mex file for Real Time Execution ,Please ensure y
github添加ssh key报错Key is invalid. Ensure you've copied the file correctly
提交到github报错Please tell me who you are
github 提交使用git commit,报错Please tell me who you are
Git---报错:git Please move or remove them before you can merge 解决方案