ayj
ayj

Reputation: 33

QueryDSL-maven-You need to run build with JDK or have tools.jar on the classpath

I have same question like this,and I have tried the two solutions,but none works for me.

I copied the configuration for querydsl from it's github page .

So my querydsl maven dependency:

    <dependency>
        <groupId>com.querydsl</groupId>
        <artifactId>querydsl-jpa</artifactId>
        <version>4.1.4</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.1</version>
    </dependency>

And my apt configuration:

        <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>apt-maven-plugin</artifactId>
            <version>1.1.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources/java</outputDirectory>
                        <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.querydsl</groupId>
                    <artifactId>querydsl-apt</artifactId>
                    <version>4.1.4</version>
                </dependency>
            </dependencies>
      </plugin>

I also modified eclipse.ini,add follow at first line:

-vm
D:\Program Files\Java\jdk1.8.0_91\bin\javaw.exe

But I till get the same error in eclipse:

You need to run build with JDK or have tools.jar on the classpath.If this occures during eclipse build make sure you run eclipse under JDK as well (com.mysema.maven:apt-maven-plugin:1.1.3:process:default:generate-sources)

And when I run mvn genarate-sources in cmd,same error occurs:

[INFO] --- apt-maven-plugin:1.1.3:process (default) 
[ERROR] execute error
org.apache.maven.plugin.MojoExecutionException: You need to run build with JDK or have tools.jar on the classpath.If this occures during eclipse build make sure you run eclipse under JDK as well

Any one can help me?

Upvotes: 1

Views: 7354

Answers (3)

ayj
ayj

Reputation: 33

finally,I solved this.The reason is that I have JDK1.7 and JDK1.8 both installed on my computer,when I run java -version in cmd,it gots error bellow:

 Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion' has value '1.8', but '1.7' is required

I removed both 1.7 and 1.8,reinstall 1.8 and evertything is fine.I got QClass genarated.

So stupid i am...

Upvotes: 1

claraind
claraind

Reputation: 71

I did it finally! I've tried so many option like this and this, but no luck. Then I read this comment that saved my life, really, thank you! I follow this solution and its working suddenly! should be accepted answer in my case.

I copied tools.jar from C:\Program Files\Java\jdk1.8.0_151\lib to C:\Program Files\Java\jre1.8.0_151\lib, after i execute mvn clean install – @julio mulcue burbano

Upvotes: 1

Pons
Pons

Reputation: 1111

Please include the following line in your eclipse.ini or STS.ini in case of STS,

-vm {path_to_jdk}\jdk{your_version}\bin\javaw.exe

For more information issue

Upvotes: 2

Related Questions