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

30,951

Solution 1

Try setting this to your eclipse.ini file and restarting eclipse to make sure that it's also using your JDK:

-vm
C:\jdk1.7\bin\javaw.exe

Cautions:

  • this must go just above -vmargs
  • you're full path to your VM maybe different than the one above

See this as reference.

Solution 2

By default, eclipse will uses the "C:\Program Files\Java\jre7".

Change it, to use "C:\Program Files\Java\jdk1.7.0_xx".

enter image description here

Solution 3

This small trick worked for me.

I tried creating a shortcut of eclipse on desktop. Right click -> properties -> Target

edit the target path as follows.

After .exe append the following

-vm "C:\Program Files\Java\jdk1.8.0_201\bin"

this should look something like this(I was using sts)

C:\Users\User\Downloads\sts-bundle\sts-3.9.7.RELEASE\STS.exe -vm "C:\Program Files\Java\jdk1.8.0_201\bin"

Click apply

Open the eclipse from shortcut and try.

Solution 4

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

Solution 5

I had to remove JRE from my installed JREs to make it work. Go to perefrences>Java>Installed JREs, remove jre and select jdk.

Share:
30,951
Pearl Jade
Author by

Pearl Jade

Young and enthusiastic about development and pearls.

Updated on July 18, 2022

Comments

  • Pearl Jade
    Pearl Jade almost 2 years

    I'm using Eclipse Luna to develop java maven applications.

    I am, or was, but am again now, using jdk1.7 as my default installed JRE.

    After an update from SVN that I made, I started getting this error on my pom.xml files:

    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.0.6:process:default:generate-sources)
    

    I noticed that my jdk1.7 installation was GONE from eclipse somehow. I've tried all the options that I've found here on stackoverflow about re-adding that jdk1.7 and setting it as my project's JRE library and even adding the tools.jar to the jdk1.7 library on eclipse, but I'm still getting the error, which makes very little sense now.

  • TomasMolina
    TomasMolina about 7 years
    For a mistake, i clicked for pull down your post. i've tried undo but i can't do.
  • Avinash
    Avinash over 5 years
    This worked for me. Thanks. I change the Path to C:\Program Files\Java\jdk1.8.0_181\bin and it works like a charm
  • Tan
    Tan almost 5 years
    This worked for me as well. My location looks like this after modification C:\my_softwares\Eclipse\eclipse\eclipse.exe -vm "C:\Program Files\Java\jdk1.8.0_211\bin"
  • IndexOutOfDevelopersException
    IndexOutOfDevelopersException over 4 years
    Thank you! But why did my project worked with jre for two weeks and than suddenly errors with pom file? I have also noticed that today was some Java update on my dev pc