When I add this code below in my pom.xml
to support Querydsl
SOLUTION 1
Following this link
"The Maven APT plugin has a known issue that prevents its usage directly from Eclipse. Eclipse users must create the Querydsl query types manually by running the command mvn generate-sources at command prompt."
So i execute the command line mvn generate-sources
in my project floder with console cmd
and i got my Qclasses generated.
SOLUTION 2 from @informatik01 comment
we can explicitly specified JVM in the eclipse.ini
like that :
-vm
C:\Program Files\Java\jdk1.7.0_45\bin\javaw.exe
-vmargs
...
The -vm
option must occur before the -vmargs
option and for more info read @informatik01 comment below.
I had done everything suggested above but to no avail. Finally, because I was setting up a new computer, I realized I didn't have a JAVA_HOME
variable set up.
So all I did was to add the JAVA_HOME
variable to my system variables and set that to a JDK path: C:\Program Files\Java\jdk1.8.0_172
And voila - mvn generate-resources
started working again.
If you build by shell commond like mvn install. Then run this command in the shell or cmd window: echo $CLASSPATH. This command shows your classpath.
If you are using Eclipse, open Window > Preferences > Java > Installed JREs, make sure your installed JREs are of jdk root location. For me, it is C:\Java\jdk1.7.0_51
Hope it helps.
Don't forget to check the setting of the Execution Environment in in your Eclipse Project Settings: Project Build Path -> Libraries -> JRE System Library.
If this is wrong (e.g. jre), switch this to a jdk one.
In my case, this solved the issue ("You need to run build with JDK or have tools.jar on the classpath." disappeared).
Then the approx. fourth line in the Maven Run Log changes from (e.g.)
...
Java home: C:\Program Files\Java\jre1.8.0_66
....
to
...
Java home: C:\Program Files\Java\jdk1.8.0_66\jre
...
Hope this helps.
This issue was happening to me because as mentioned above, Eclipse itself was running through the JRE instead of the JDK.
I solved it by adding %JAVA_HOME%\bin to the front of my PATH environment variable.
I figured out what JVM eclipse was using by reading through: Find out what JVM Eclipse is running on
<groupId>com.mysema.maven</groupId>
<artifactId>maven-apt-plugin</artifactId>
<version>1.0.6</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.mysema.query.apt.jpa.JAPAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
add the plugin ,you will solve it