[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a

 

2017年02月06日 16:58:58 BlueBlueSkyZ 阅读数:3423

我在学习maven时遇到了这个报错,找到了这位外国友人写的博客。 
http://www.kriblog.com/ide/sts/error-no-compiler-is-provided-in-this-environment.-perhaps-you-are-running-on-a-jre-rather-than-a-jdk.html 
他提供了三种方法: 
第一个修改jre的我自己试过好像没用; 
第二个据说是最好的方法然而我还没接触Spring,因而作罢; 
第三个亲自试验确实可行,然而却不能一劳永逸。 
也希望有高手能来指点迷津。。


对我来说今天真是糟糕的一天,我花了许多时间下载最新的 Spring Tool Suite based on Eclipse 4.4.1 压缩版,但是现在出现了下面的错误。

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.162 s
[INFO] Finished at: 2014-12-30T02:13:56+05:30
[INFO] Final Memory: 8M/19M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project demo: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

有人知道这个问题吗?先提前感谢一下。

提问自Navdeep于2014-12-16 09:36:03.0


你可以选择以下任意方式解决[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

方法1

  • 点击 Windows -> Preferences -> Java -> Installed JREs -> Add -> Standard VM, 然后选择JAVA_HOME 
    JAVA_HOME
  • 从已经安装的JRE中选择新的JRE并点击OK 
    JRE

方法2

最简单并且在所有场景中都适用

  • 第一步-打开Spring Tool Suite(STS)的安装目录
  • 第二步-右击STS.ini
  • 第三步-打开 -VM JAVA_HOME/bin/javaw.exe然后重启Eclipse Spring Tool Suite (STS),Eclipse将会自动获得这个JDK
 -vm
G:/jdk1.7.0_25/bin/javaw.exe
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20140603-1326
-product
org.springsource.sts.ide
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms40m
-Xmx768m
-XX:MaxPermSize=256m
-Dorg.eclipse.swt.browser.IEVersion=10001
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

方法3

打开pom.xml,输入以下高亮部分并将正确的JDK路径输入。(不支持部分高亮,start至end部分)

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <!--start-->
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                    <fork>true</fork>
                       <executable>
                       D:\jdk1.7.0_25\bin\javac.exe
                      </executable>
            </configuration>
        </plugin>
        <!--end-->
    </plugins>
</build>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

祝你好运!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值