미니옵빠의 code stubs
Eclipse 에서 Unable to locate the Javac Compiler in 등 Maven Compile을 실패할 경우 본문
Eclipse 에서 Unable to locate the Javac Compiler in 등 Maven Compile을 실패할 경우
미니옵빠 2014. 10. 16. 22:23컴파일 시 Eclipse 가 뜰때 사용한 JVM 과 동일한 JVM 을 사용하기 때문에 발생.
안 겹치게 수정을 잘...
(Eclipse 가 사용하는 시스템 path 는 jre를 걸고, Eclipse 내의 compiler 는 JDK 를 사용한다던가,
JDK 1.7 / 1.8 두 개를 설치하고 각 경우 다른 JDK 를 쓰게 한다던가)
http://wiki.eclipse.org/M2E_FAQ
Unable to locate the Javac Compiler Error
Some users reported the following error that happens when importing Maven projects or when invoking "Update Sources" action.
6/25/07 1:15:44 PM CDT: ERROR mojo-execute : compiler:compile : Compilation failure Unable to locate the Javac Compiler in: C:Program FilesJavaj2re1.4.2_14..libtools.jar Please ensure you are using JDK 1.4 or above and not a JRE (the com.sun.tools.javac.Main class is required). In most cases you can change the location of your Java installation by setting the JAVA_HOME environment variable.
That happens because those actions runs in the same JVM where Eclipse is running. If that JVM comes from JRE that isn’t part of JDK, there is no Java compiler (the tools.jar) around. To workaround this you can add -vm argument to Eclipse command line or eclipse.ini. For Eclipse 3.3 it would look something like this:
-showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m -vm C:\jdk1.6.0\bin\javaw.exe -vmargs -Xms40m -Xmx256m
Alternatively you could specify compilerId in the pom.xml, so Maven won’t be looking for JDK when compiling Java code:
<plugin> <artifactid>maven-compiler-plugin</artifactid> <configuration> <compilerid>eclipse</compilerid> </configuration> <dependencies> <dependency> <groupid>org.codehaus.plexus</groupid> <artifactid>plexus-compiler-eclipse</artifactid> <version>xxxx</version> </dependency> </dependencies> </plugin>
Also note that to launch Maven from within Eclipse, JRE used for launch also need to come from JDK. By default Eclipse registers JRE it is started in, but this can be configured on "Window / Preferences… / Java / Installed JREs" preference page.