解决cmd下Maven打包报Perhaps you are running on a JRE rather than a JDK?错误
1.在cmd窗口下输入:mvn -v
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)
Maven home: D:\maven\apache-maven-3.6.0\bin…
Java version: 1.8.0_191, vendor: Oracle Corporation, runtime: C:\Program Files\Java*jre1.8.0_191*
Default locale: zh_CN, platform encoding: GBK
OS name: “windows 10”, version: “10.0”, arch: “amd64”, family: “windows”
可以看到运行环境是在jre上,接下来修改为jdk.
2.找到你的maven安装路径,我的是D:\maven\apache-maven-3.6.0
在D:\maven\apache-maven-3.6.0\bin路径下找到mvn.cmd文件。添加这一句:
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_191
C:\Program Files\Java\jdk1.8.0_191为你java的Jdk安装路径。每个人安装的路径可能不一样,填你自己的。
3.在cmd窗口下再次输入:mvn -v
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)
Maven home: D:\maven\apache-maven-3.6.0\bin…
Java version: 1.8.0_191, vendor: Oracle Corporation, runtime: C:\Program Files\Java*jdk1.8.0_191\jre*
Default locale: zh_CN, platform encoding: GBK
OS name: “windows 10”, version: “10.0”, arch: “amd64”, family: “windows”
出现粗体字证明问题已解决。