No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?(Mac)
前言
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
翻译 : 此环境中不提供编译器。也许您在 JRE 而不是 JDK 上运行?
考虑可能是因为运行环境真的是在JRE 而不是 JDK 上运行
Mac
环境- 打包编译
dubbo-samples-protobuf
时
思路
检查 Maven
命令
mvn -version
Apache Maven 3.6.0 (.......)
Maven home: /usr/local/maven3
Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Default locale: zh_CN, platform encoding: UTF-8
OS info....
检查 Java
命令
java -version
$ java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
- 有多
jdk
版本, 检查可能有误
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (4):
13.0.2 (x86_64) "Oracle Corporation" - "Java SE 13.0.2" /Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home
11.0.7 (x86_64) "Oracle Corporation" - "Java SE 11.0.7" /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home
1.8.221.11 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
1.8.0_221 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home
结合上面两类命令的检查, 大致定位为 Mac
系统升级的问题
解决办法
为 Maven
指定 JDK
路径
- 查看
Maven
的安装路径:mvn -version
Apache Maven 3.6.0 (.......)
Maven home: /usr/local/maven3
Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Default locale: zh_CN, platform encoding: UTF-8
OS info....
- 进入
Maven
安装目录的bin
目录:cd /usr/local/maven3/bin
$ cd /usr/local/maven3/bin
m2.conf
mvn
mvn.cmd
mvnDebug
mvnDebug.cmd
mvnyjp
- 编辑文件
mvn
:vim mvn
, 在文件开头添加一行声明:
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home
- 保存后退出(
:wq
) - 再次打包编译
dubbo-samples-protobuf
成功
参考来源
Macbook idea:No compiler is provided in this environment. Perhaps you are running on a JRE...