0

JAVA_HOME does not point to the JDK.(Spring Tool Suite)

I am getting an error while running Spring Tool Suite(3.9.5.RELEASE) as

org.apache.tools.ant.BuildException: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files\Java\jre1.8.0_181"

As i already set the java path in Environmental Variable-->System variables as Variable Name : JAVA_HOME and Variable Value : C:\Program Files\Java\jdk1.8.0_131

and in Environmental Variable-->user variables as

Variable Name : path and Variable Value : C:\Program Files\Java\jdk1.8.0_131

and in my C:\Program Files\Java\ drive there is jdk1.8.0_131 and jre1.8.0_181.

I set the path properly to JDK, also I restarted the application too, even restarted the Computer too, still I am getting the same error again.

Is there any other solution to avoid such error?

Fullstack Guy
  • 16,368
  • 3
  • 29
  • 44
Arvik Shukla
  • 1
  • 1
  • 2
  • is javac working on cmd? – Robert Ellis Sep 09 '18 at 17:21
  • Yes, its working fine – Arvik Shukla Sep 09 '18 at 17:38
  • hey buddy JAVA_HOME should point to jdk not jre example of my path in linux /usr/local/jdk1.8.0_171 – Robert Ellis Sep 09 '18 at 17:56
  • check out this link https://stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7 .try echo %JAVA_HOME% in cmd see if the correct path is set – Robert Ellis Sep 09 '18 at 17:59
  • i did all the settings properly, as provided link by you..Now the the error coming as: Perhaps JAVA_HOME does not point to the JDK. It is currently set to "C:\Program Files\Java\jdk1.8.0_131\jre" as i set the path to jdk and jre creaed inside JDK , hence i unable to run the Spring boot app, frustated a lot with this error.. – Arvik Shukla Sep 10 '18 at 16:15

2 Answers2

1

Check your project build path if it is pointing to JRE instead of JDK.

Else Check,

  1. The path for the tools.jar, if it is wrong? or,
  2. Is it pointing to an older version of Java? or,
  3. If tools.jar is missing?

If all the above options do not work try reinstalling JDK.

Pallav Kabra
  • 418
  • 3
  • 7
  • i did all the settings properly, but it still shows the error as: Perhaps JAVA_HOME does not point to the JDK. It is currently set to "C:\Program Files\Java\jdk1.8.0_131\jre" – Arvik Shukla Sep 10 '18 at 16:14
  • 1
    Set `JAVA_HOME="C:\\....\java\jdk1.x.y_zz"` and set `PATH=%PATH%;%JAVA_HOME%\bin` – Pallav Kabra Sep 10 '18 at 16:44
  • did, but still shows as JAVA_HOME does not point to the JDK. and when i checked in cmd prompt it shows the correct path of JDK .It is currently set to "C:\Program Files\Java\jdk1.8.0_131\jre", as it pointed to JDK but, inside JDK it point to JRE folder where its create a problemi wanna get rid of this .. tough for me – Arvik Shukla Sep 10 '18 at 17:07
  • @ArvikShukla remove the jre at the end C:\Program Files\Java\jdk1.8.0_131\jre it should be C:\Program Files\Java\jdk1.8.0_131 – Robert Ellis Sep 11 '18 at 08:34
  • @Manoj Ramanan i set the path as C:\Program Files\Java\jdk1.8.0_131 by gooing to Windows-->Preference-->Add-->and the i set the JRE home as C:\Program Files\Java\jdk1.8.0_131, but when i try to check build path by right click on project-->BuildPath-->Configured Build Path--> i see that it configured to C:\Program Files\Java\jdk1.8.0_131\jre, but i set the path path till JDK,its beyond understand why its point to jre even after setting the path till jdk.. – Arvik Shukla Sep 11 '18 at 15:19
  • 1
    First of all delete all the path you set for JAVA in environment variable And then as I mentioned Set `JAVA_HOME="C:\\....\java\jdk1.x.y_zz"` and set `PATH=C:\\...\java\jdk1.x.y_zz"\bin`. Follow these steps for above mentioned `https://www.java.com/en/download/help/path.xml`. – Pallav Kabra Sep 11 '18 at 20:45
  • Follow these steps for eclipse setting https://techiedan.com/2009/10/19/set-up-jdk-in-eclipse/ – Pallav Kabra Sep 11 '18 at 20:54
  • @Pallav Kabra, The link you provided to set up the JDK in eclipse, i did this exactly as shown there in the link , and if you notice, look at the 3rd image (EDIT JRE window)where the path is pointing to JRE as C:\Program Files\Java\jdk1.8.0_131\jre, there i gettinga problkem that as error show to me is Perhaps JAVA_HOME does not point to the JDK. It is currently set to "C:\Program Files\Java\jdk1.8.0_131\jre" – Arvik Shukla Sep 12 '18 at 07:21
  • and also i added dependency from my side as org.apache.ant ant 1.8.2 as previously tomcat was not running so i added ant dependency so its started to detect embeded tomcat but niow after solving that problem now it shows this Point to JRE errors.. i think its due to dependency of ant it shows me a problem ?? – Arvik Shukla Sep 12 '18 at 07:26
0

I installed STS in eclipse Python instead of using separate STS tool and problem got solved..Still wonder why the path shows in STS tool point to jre even after setting to JdK...but i install and run STS in eclipse and it worked properly, wasted my 2 days on this error. Thanks for your time , learned a lot about settings from you guys

Arvik Shukla
  • 1
  • 1
  • 2