No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK 问题解决
1. 问题描述
使用idea对Java工程执行mvn compile
命令进行编译,出现以下报错:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5:compile (default-compile) on project test: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
2. 问题分析
从报错信息上看,是由于环境没有提供编译器,可能编译过程运行在JRE上,而不是JDK上。
查看了idea项目配置的Java编译器为JDK8,且配置的Java路径正确。
执行命令mvn -v
,查看maven的配置。发现runtime的路径有些奇怪。
Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: /usr/local/apache-maven-3.8.3
Java version: 1.8.0_311, vendor: Oracle Corporation, runtime: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"
3. 解决方案
从网上搜索了解决方案,发现这篇文件介绍的比较靠谱。
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
采用了文章中的方法3,重新设置JAVA_HOME
路径。
- 添加Java环境变量
# cat ~/.bash_profile
export M2_HOME=/usr/local/apache-maven-3.8.3
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home
export PATH=$PATH:$M2_HOME/bin:$JAVA_HOME/bin
- 使环境变量生效
source ~/.bash_profile
- 查看maven配置
# mvn -v
Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: /usr/local/apache-maven-3.8.3
Java version: 1.8.0_311, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"
发现maven的runtime运行环境已经正常。
此时再次执行编译命令mvn compile
,发现Java工程可以正常编译,不在出现报错。
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK 问题解决的更多相关文章
- No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK问题解决
Maven构建项目报错: 解决办法: 1.eclipse菜单 - Window - Preferences- Java - Installed JREs 将配置的JRE定位到JDK,例如JRE ho ...
- Maven No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? 问题
maven编译项目时出错,提示信息如下: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3 ...
- No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
以前用MyEclipse,现在用eclipse配置maven后,运行run install.报错: [ERROR] No compiler is provided in this environmen ...
- maven No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
maven install项目时出错,提示信息如下: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-pl ...
- Maven异常: No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK解决(能力工场小马哥)
问题描述: No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JD ...
- No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? 问题
maven编译项目时出错,提示信息如下: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3 ...
- Maven构建项目出现No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? 你应该 ...
- maven install 报错 No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
1.控制台打印信息 [INFO] Scanning for projects... [INFO] [INFO] ---------------------< org.cqupt.mauger:R ...
- 【maven】maven的web项目打包报错:No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK
打包过程中报错如下: No compiler is provided in this environment. Perhaps you are running on a JRE rather than ...
随机推荐
- JuiceFS 即将发布 1.0 并调整开源许可
开源一周年 JuiceFS 开始于 2017 年,是一款云原生分布式文件系统,旨在帮助企业解决多云.跨云.混合云环境下所面临的诸多挑战:数据安全和保护.大数据架构升级.海量小文件访问.Kubernet ...
- PIKACHU之文件包含漏洞
PIKUCHU靶场之文件包含 一.file inclusion(local) 实验源码: <?php /** * Created by runner.han * There is nothing ...
- Cesium入门8 - Configuring the Scene - 配置视窗
Cesium入门8 - Configuring the Scene - 配置视窗 Cesium中文网:http://cesiumcn.org/ | 国内快速访问:http://cesium.coini ...
- C++Template(类模板二)
namespace _myspace{ template<typename T, typename U> class TC { public: TC() { cout << & ...
- 【webpack4.0】---webpack的基本使用(三)
一.webpack-dev-server 1.安装 cnpm install webpack-dev-server -D 2.作用 开启一个web服务,监听文件的变化并自动刷新网页,做到实时预 ...
- web.xml最新配置
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmln ...
- linu查看系统用户与显示命令行提示符格式信息
目录 一:查看系统用户whoami 二:显示命令行提示符格式信息变量 一:查看系统用户whoami whoami : 当前窗口登录的用户 who : 当前用户登录系统的终端 作用: 显示当前用户登录了 ...
- 带你十天轻松搞定 Go 微服务系列(五)
序言 我们通过一个系列文章跟大家详细展示一个 go-zero 微服务示例,整个系列分十篇文章,目录结构如下: 环境搭建 服务拆分 用户服务 产品服务 订单服务(本文) 支付服务 RPC 服务 Auth ...
- AT2657 [ARC078D] Mole and Abandoned Mine
简要题解如下: 记 \(1\) 到 \(n\) 的路径为关键路径. 注意到关键路径只有一条是解题的关键,可以思考这张图长什么样子. 不难发现关键路径上所有边均为桥,因此大致上是关键路径上每个点下面挂了 ...
- 关于diffing算法中key的使用
在vue和react中(只学了这两个),经常需要渲染元素到DOM上,而且如果不写key,有的浏览器会进行报错或者进行提示. 在我的理解里:key其实就是一个身份的标识,证明这个位置坐的就是这个人.后期 ...