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 ...
随机推荐
- uni-app开发的h5,使用微信授权登录(前置条件+具体代码)
原文 微信内嵌浏览器运行H5版时,可以调起微信登录 普通浏览器调起微信登陆是不开放的,只有个别开发者才有,比如京东 前置条件 在微信内嵌浏览器运行H5版时,调起微信登录,需要配置回调域名 (请注意,这 ...
- AVD模拟器怎么配置上网
转自:http://blog.csdn.net/you_jinjin/article/details/7228303 方法一 首先,Windows下,配置Adroid环境变量(Win7为例) 1.桌面 ...
- C#获取http图片
public Image GetHttpImage(string url) { var client = new HttpClient(); var uri = new Uri(Uri.EscapeU ...
- dgv 自动换行
//设置自动换行 dgv.DefaultCellStyle.WrapMode = DataGridViewTriState.True; //设置自动调整高度 dgv.AutoSizeRowsMode ...
- Java对象栈上分配
转自 https://blog.csdn.net/o9109003234/article/details/101365108 在学习Java的过程中,很多喜欢说new出来的对象分配一定在对上: 其实不 ...
- 观察者模式(Observer模式)
模式的定义与特点 观察者(Observer)模式的定义:指多个对象间存在一对多的依赖关系,当一个对象的状态发生改变时,所有依赖于它的对象都得到通知并被自动更新.这种模式有时又称作发布-订阅模式.模型- ...
- Servlet-base标签的作用(相对路径和绝对路径)
Web中的相对路径和绝对路径 在javaWeb中,路径分为相对路径和绝对路径: 相对路径: . 表示当前目录 .. 表示上一级目录 资源名 表示当前目录/资源名 绝对路径: http://ip ...
- python全局解释器GIL锁(-死锁)
目录 一:Python中的GIL锁 1.GIL介绍 2.GIL的作用 3.cpython 4.内存管理>>>垃圾回收机制 二:全局解释器锁GIL 1.GIL特点 三:计算密集型与IO ...
- Open虚拟专用网络
目录 一:OpenVPN虚拟网络专用 1.简介: 2.OpenVPN的作用 3.远程访问VPN服务 4.OpenVPN两种类型的VPN体系结构 5.全面解析OpenVPN执行流程 6.Openvpn定 ...
- python函数位置实参传参
#!/usr/bin/python #coding=utf-8 #好好学习,天天向上 def describe_pet(type,name): print(f"i have a {type} ...