0
votes

Because I was having problems, I opened a command window and changed to the very bin directory where ant was installed. Then I entered 'ant -version'. It returned:
         Files\Java\jdk1.8.0_72"" was unexpected at this time.
Entering 'ant' alone gives the same message. The JAVA_HOME is set to the jdk folder (jsk1.8.0_72), and the PATH adds \bin to it. Nothing else appears broken.

Any ideas gratefully received. Thank you.

Since writing the above,

  1. I tried shifting to 32-bit jdk7 from 64-bit jdk8. Output from "ant --version" changed a bit to: Files was unexpected at this time.
  2. Changing the Symlinks in C:\ProgramData\Oracle\Java\javapath did nothing good.
  3. Output of "set | findstr /b /i //"java_home=//"" is:
         JAVA_HOME="C:\Program Files (x86)\Java\jdk1.7.0_79"
  4. For PATH=, the output is too long and characters could be missed, so instead I ran: echo %PATH% > d.txt. Here is the result:

    C:\Program Files\Everything;C:\Program Files\gradle-2.8\bin;"C:\Program Files (x86)\Launch4j";C:\Program Files (x86)\Apache\apache-ant-1.9.6\bin;"C:\Program Files (x86)\Java\jdk1.7.0_79"/bin;C:\cygwin64;C:\cygwin64\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Windows Resource Kits\Tools\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\curl;C:\Devkit\bin;C:\Ruby21-x64;C:\Ruby21-x64\bin;C:\Perl64\site\bin;C:\Perl64\bin;C:\Program Files (x86)\Apache\apache-ant-1.9.0\bin;"C:\Program Files (x86)\Java\jdk1.7.0_79"\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files (x86)\GNU\GnuPG\pub;C:\Program Files (x86)\WinMerge;C:\Program Files (x86)\Bazaar;C:\Program Files\jEdit;C:\Program Files (x86)\Groovy\Groovy-2.1.7\bin;C:\Program Files\MySQL\MySQL Server 5.1\bin;C:\Program Files (x86)\Calibre2\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\CMake\bin;C:\Program Files (x86)\mingw-w64\i686-4.9.2-posix-dwarf-rt_v4-rev2\mingw32\bin;C:\Program Files (x86)\Scite\scite\bin;C:\Program Files (x86)\nodejs\;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Tcl\bin;C:\Program Files (x86)\Arduino\hardware\tools\avr\bin;C:\Program Files\dbd\Beard;C:\Program Files\dbd\dd;C:\Users\dbd\AppData\Roaming\npm


Please note that all the Java Demos run OK, suggesting that the basic java installation is OK.. Have not yet looked at the Registry. All of this is mysterious and upsetting.

Thanks to Stefan De Laet and Chad Nouis. More to be done.
2
try adding quotes to the JAVA_HOME="C:\Program Files\Java\jdk...." definition in your environment variablesStefan De Laet
Open a new Command Prompt and run the following commands: set | findstr /b /i "path=" and set | findstr /b /i "java_home=". Then edit your question with the output of those commands.Chad Nouis
Much later: Digging into the basics of starting ant:<br>Daniel B. Davis

2 Answers

0
votes

This entry in your PATH doesn't look quite right:

"C:\Program Files (x86)\Java\jdk1.7.0_79"/bin

Those quotation marks shouldn't be there. Also, the forward slash before bin should be replaced with a backslash:

C:\Program Files (x86)\Java\jdk1.7.0_79\bin

Next, the JDK directories appear twice in your PATH:

...;"C:\Program Files (x86)\Java\jdk1.7.0_79"/bin;...;"C:\Program Files (x86)\Java\jdk1.7.0_79"\bin;...

Only one JDK directory is necessary. I recommend deleting the second entry.

Further, your JAVA_HOME also shouldn't have quotation marks. The following...

JAVA_HOME="C:\Program Files (x86)\Java\jdk1.7.0_79"

...should be...

JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_79
0
votes

At long last and finally, 'ant -version' gets the correct response: "Apache Ant(TM) version 1.9.6 compiled on June 29 2015". I beiieve several things contributed to the success:

  • Switching from 64-bit to 32-bit java. Since Ant comes as a zip file, I could not discover whether it is really 64-bit or 32-bit. I did find it in my 32-bit folder, but that could be a holdover from earlier times. But maybe not.
  • fixing the PATH. The PATH which I sent was an end-result after substitution composed of a replacement for the following: "...%JAVA_HOME%/bin...". Normally, I would have spotted it, but because of the %, I did not. Thank you Chad Nouis! When I switched to 32-bit, I did not touch the PATH entry, but merely changed JAVA_HOME. This may have been in the system for some time.

Oh Well! Have a good day everyone and thanks again!