3 Replies Latest reply: Feb 23, 2009 1:04 PM by 843804 RSS

    Error: JAVA_HOME is not defined correctly - While running ant.

    843804
      I have upgraded the JDK 1.5 Update 10 to Update 14. After upgrading the ant is failing when using with cygwin.

      It's giving the below error message:
      Error: JAVA_HOME is not defined correctly.
      We cannot execute /cygdrive/c/Java/jdk14/bin/java

      The JAVA_HOME is set properly & even I am able to check java -version.

      I am using apache-ant-1.6.5 and cygwin.

      Have any one faced the same problem?

      Please let me know if you have any solutions
        • 1. Re: Error: JAVA_HOME is not defined correctly - While running ant.
          843804
          I met the same error when I run ant script in the crontab.
          I use "root" account run ant and it work well, but when I put ant into crontab, I got the error message.
          • 2. Re: Error: JAVA_HOME is not defined correctly - While running ant.
            843804
            It seems your current user doesn't have "execute" rights for java.exe. Try doing chmod for that, it may work.
            • 3. Re: Error: JAVA_HOME is not defined correctly - While running ant.
              843804
              Grrrr. Been having a similar problem, but with Maven2. Allow me to (hopefully) save someone the gnawing of teeth and several bald patches.

              For starters, the Maven documentation gives you a pretty clear example of how to set your PATH. This is as follows:

              export PATH=/usr/whatever/whateveragain/apache-maven-2.0.10/bin:$PATH

              Simple, eh? Note the colon before $PATH. Then, it states quite presumptuously "4) Make sure JAVA_HOME is set to the location of your JDK". However, you don't set it in exactly the same way. You set it in virtually the same way, except without the colon, like this:

              export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0$JAVA_HOME

              Note that if you get the paths wrong a couple of times, you may reset them with the unset command. So to unset JAVA_HOME you'd use:

              unset JAVA_HOME

              After which you may set it again. As is advised, you may try to set the user privileges, but they didn't seem to affect my luck at all. Hope this helps!