1. 程式人生 > >解決Perhaps you are running on a JRE rather than a JDK?問題

解決Perhaps you are running on a JRE rather than a JDK?問題

轉自:http://www.bubuko.com/infodetail-743907.html

Maven-No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

技術分享

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building helloworld 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ helloworld ---
[INFO] Deleting H:\mavenok\helloworld\
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloworld ---
[INFO] Using ‘UTF-8‘ encoding to copy filtered resources.
[INFO] skip 

non existing resourceDirectory H:\mavenok\helloworld\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ helloworld ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to H:\mavenok\helloworld\\classes
[INFO] -------------------------------------------------------------
[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: 0.781 s
[INFO] Finished at: 2015-03-25T11:22:14+08:00
[INFO] Final Memory: 4M/8M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to exe
cute
 goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project helloworld: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X  to enable full debug logging.
[ERROR] 
[ERROR] For more 
info
rmation about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

問題描述:No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

翻譯過來就是,大哥,環境裡沒給編譯器呀,可能你是用jre在玩耍,我要jdk~~

問題原因:eclipse官網看了看,發現eclipse預設是執行在jre上的,
但是maven外掛需要使用jdk,因此需要在eclipse修改Installed JRES
位置在-->【Window】-->【Prefrences】-->【Java】-->【Installed JREs】
詳見下圖。

技術分享

這樣就解決了這個問題,重新構建一下

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building helloworld 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ helloworld ---
[INFO] Deleting H:\mavenok\helloworld\
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloworld ---
[INFO] Using ‘UTF-8‘ encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory H:\mavenok\helloworld\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ helloworld ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to H:\mavenok\helloworld\\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.117 s
[INFO] Finished at: 2015-03-25T11:45:51+08:00
[INFO] Final Memory: 6M/12M
[INFO] ------------------------------------------------------------------------

構建成功。

技術分享



參考自:http://www.cnblogs.com/shenshuyi/archive/2012/10/17/2727815.html

對於m2eclipse的外掛,需要eclipse運行於jdk而不是jre, 開啟eclipse,看到錯誤“Eclipse is running in a JRE, but a JDK is required”

解決方法:

在eclipse目錄下eclipse.ini,新增如下兩行,注意這行要加在-vmargs之前,

-vm 
D:\Program Files\Java\jdk1.7.0_07\bin\javaw.exe

比如我的檔案如下:

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20120522-1813
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vm 
D:\Program Files\Java\jdk1.7.0_07\bin\javaw.exe 
-vmargs
-Xms40m
-Xmx512m


執行了Run as-run configrations


發現這個裡面的runtime jre竟然還是設定在Alternate JRE上面,把它設定到Workspace default JRE上就可以了。