You need to run the build using the JDK or have tools.jar in the classpath

I am using Eclipse Luna to develop java maven applications.

I, or was, but now again, using jdk1.7, since my default is JRE.

After updating from SVN that I created, I started getting this error in 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 tried all the options that I found here in stackoverflow about re-adding this jdk1.7 and installing it as my project JRE library and even adding tools.jar to jdk1.7 library on eclipse, m still gets the error, what now very little meaning.

+12
source share
5 answers

Try installing it in the eclipse.ini file and restart eclipse to make sure it also uses your JDK:

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

Caution:

  • it should go just above -vmargs
  • your full path to the virtual machine may differ from the above

See this as a link.

+24
source

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

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

enter image description here

+5
source

This little trick worked for me.

I tried to create a desktop eclipse shortcut. Right click -> Properties -> Target

change the target path as follows.

After .exe add the following

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

it should look something like this (I used 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 the shortcut and try.

+2
source

I had to remove the JRE from my installed JREs in order for this to work. Go to perefferences> Java> Installed JREs, uninstall jre and select jdk.

+1
source

I did it finally! I tried as many options as this and this , but no luck. Then I read this comment , which saved my life, really, thanks! I follow this decision and it works suddenly! the answer should be accepted 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 doing a clean mvn installation - @julio mulcue burbano

+1
source

Source: https://habr.com/ru/post/1209764/


All Articles