centos下maven编译 mvn package 报错:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project helloworld: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
答案:
32
down vote
accepted
Apparently,it requires tools.jar file inside the lib folder of my $JAVA_HOME. I did not have the lib folder,so I reinstalled my jdk using command
apt-get install openjdk-7-jdk openjdk-7-doc openjdk-7-jre-lib
Also,this link may help some people.
shareimprove this answer
注意,假如你是jdk8的请将7替换成8。
centos 用这个
yum -y install openjdk-8-jdk openjdk-8-doc openjdk-8-jre-lib
解决方案
在centos7的terminal中输入java -verison是没问题的,但是javac的话就会提示没有此命令
百度了好久,说的很复杂,照着做了,最后也没有成功
后来在stackoverflow上看到了这个
84 down vote accepted
You installed the Java Runtime Environment (JRE) only,which does not contain javac. For javac,you have to install the OpenJDK Development Environment. You can install java-devel or java-1.6.0-openjdk-devel,which both include javac.
By the way: you can find out which package provides javac with a yum search,e.g.
su -c ‘yum provides javac’
Another note: using yum and openjdk is only one possibility to install the JDK. Many people prefer Sun/Oracle’s “original” SDK. See How to install Java SDK on CentOS? and links for alternatives.
大意就是我们用yum来装原生的就行了 使用 yum install java-devel 就行了