Xmlbeans-maven-plugin does not find javac

I am trying to configure xmlbeans-maven-plugin 2.3.3 in my Eclipse and everything seems to work fine, java.io.IOException due to the inability to find the file C:\Users\Daniel\Workspace\MyProject\javac .

This is strange because javac is in the% PATH% system, so why try to find it in% PROJECT_LOC%?

I found a description of this problem , which is very similar to mine, but I put the JDK path in front of all other paths and did not do this, t help.

Any idea how to tell xmlbeans-maven-plugin where to look for javac ?

UPDATE 1: I tried to work around this problem by simply copying javac.exe to the project directory and at least now I found it, but the problem moved forward:

 java.lang.NoClassDefFoundError: com/sun/tools/javac/Main Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.Main at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) Exception in thread "main" Could not find the main class: com.sun.tools.javac.Main. Program will exit. 

Any insight that could help come up with the right solution to this (e.g. something in . M2 / settings.xml ?) Would be appreciated.

UPDATE 2: I also tried this little solution that I found in my searches:

 <settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository>c:\maven\repository</localRepository> <configuration> <compiler>C:\Program Files (x86)\Java\jdk1.6.0_37\bin\javac.exe</compiler> </configuration> </settings> 

But this did not help the plugin find javac . He still complains that "the system cannot find the specified file" for javac.exe.

+1
source share
1 answer

Found a solution! In the pom.xml project , just add the following inside the <configuration> :

 <compiler>C:\Program Files (x86)\Java\jdk1.6.0_37\bin\javac.exe</compiler> 

i.e.

  <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>xmlbeans-maven-plugin</artifactId> <version>2.3.3</version> <executions> <execution> <goals> <goal>xmlbeans</goal> </goals> </execution> </executions> <inherited>true</inherited> <configuration> <schemaDirectory>${basedir}/src/main/xsd</schemaDirectory> <compiler>C:\Program Files (x86)\Java\jdk1.6.0_37\bin\javac.exe</compiler> </configuration> </plugin> 

Also do not forget to specify Window -> Preferences -> Java -> installed JREs in the JDK, and not in the JRE: C:\Program Files (x86)\Java\jdk1.6.0_37 . As described in this thread .

+2
source

All Articles