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 ...
随机推荐
- 403 Invalid CORS request 跨域问题 invalid+cors+request什么意思
5.跨域问题 跨域:浏览器对于javascript的同源策略的限制 . 以下情况都属于跨域: 跨域原因说明 示例 域名不同 www.jd.com 与 www.taobao.com 域名相同,端口不同 ...
- mysql之突破secure_file_priv写webshell
在某些情况下,当我们进入了一个网站的phpMyAdmin时,想通过select into outfile来写shell,但是通常都会报错. 这是因为在mysql 5.6.34版本以后 secure_f ...
- 【Java】方法
文章目录 何谓方法 方法的定义 方法调用 方法重载 命令行传参 可变参数 递归 何谓方法 System.out.println(),是什么 Java方法是语句的集合,它们在一起执行一个功能 方法是解决 ...
- [µC/GUI 学习]µC/GUI移植
一.什么是µC/GUI µC/GUI为任何需要图形显示器的嵌入式应用提供了一种灵活的图形用户界面(GUI).µC/GUI允许软件工程师在使用了LCD显示器的产品上增加美轮美奂的用户界面,从简单的2D黑 ...
- 带你十天轻松搞定 Go 微服务系列(一)
本文开始,我们会出一个系列文章跟大家详细展示一个 go-zero 微服务示例,整个系列分十篇文章,目录结构如下: 环境搭建(本文) 服务拆分 用户服务 产品服务 订单服务 支付服务 RPC 服务 Au ...
- 【代码分享】用redis+lua实现多个集合取交集并过滤,类似于: select key from set2 where key in (select key from set1) and value>=xxx
redis中的zset结构可以看成一个个包含数值的集合,或者认为是一个关系数据库中用列存储方式存储的一列. 需求 假设我有这样一个数据筛选需求,用SQL表示为: select key from set ...
- 513. Find Bottom Left Tree Value
Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input: 2 / \ 1 ...
- js整体
1.引入 <script type="text/javascript"> 2.输出 使用 window.alert() 写入警告框 使用 document.write ...
- golang中的runtime包
1. runtime.Gosched 让出CPU时间片,重新等待安排任务 package main import ( "fmt" "runtime" ) fu ...
- 配置Nginx使用Active Directory 做认证
配置Nginx使用AD做认证 nginx.conf 配置 http { ldap_server ldap { url ldap://xxx:389/DC=test,DC=com?sAMAccountN ...