19

When I try to run the following command I get an error:

$ ant -Dsdk.dir=/opt/google/appengine-java-sdk runserver -Dserver.host=192.168.1.10

Here is the error:

"Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li b\tools.jar".

I have given jdk path in JAVA_HOME variable as C:\PROGRA~1\Java\jdk1.6.0_25 as my jdk location is C:\Program Files (x86)\Java\jdk1.6.0_25.

What is the issue? Please help me.Thanks in advance.

When I have tried to run the command ant -diagnostics , I got

java.home : C:\Program Files\Java\jre6
user1767260
  • 1,543
  • 8
  • 26
  • 51

2 Answers2

23

You should try adding %JAVA_HOME%\bin at the beginning of your PATH environment variable (given syntax assumes Windows of course). As Peter Knego commented, tools.jar exists in the JDK, not the JRE, so you must make sure the JAVA_HOME points to your JDK directory.

Patrice M.
  • 4,209
  • 2
  • 27
  • 36
  • 1
    %JAVA_HOME%\bin present at the end of path so changed position i.e added at the beginning of your PATH environment variable. It works!! but whats difference ? – StackOverFlow May 16 '14 at 00:52
  • 2
    Well, when the OS tries to locate an executable, it will try all the locations listed in the PATH, in the order they are listed. So if you really want something to be found, put it at the beginning, in case an executable by the same name is also found at some other locations. That's probably what caused your problem: either another java executable can be found in one of the existing PATH locations, or somehow you jumbled the PATH syntax somewhere in the middle and the last portion of the PATH is unusable. At leat that's the most likely causes. – Patrice M. May 16 '14 at 15:32
  • 1
    %JAVA_HOME%\lib at beginning of path, if you want to load tools.jar – Martin Capodici Aug 19 '14 at 04:55
2

You are probably building some project that has the old file called local.properties at the project root level. There is a sdk.dir property there and it is pointing wrongly. Open that file with editor and correct.

Also, your command line looks questionable. There you specify the sdk location using some Unix path and from the rest of you message looks you are on Windows. Be sure that property matches your sdk location. It may not be actually required at all.

Audrius Meškauskas
  • 20,936
  • 12
  • 75
  • 93