ant script ?

Programming, for all ages and all languages.
Post Reply
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

ant script ?

Post by Sam111 »

Hi , I never worked with ant scripts before and I am getting this error when I try to use my build.xml that I created

Code: Select all

<project name="Testing" default="dist" basedir=".">
    <description>
        simple example build file
    </description>
  <!-- set global properties for this build -->
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="dist"  location="dist"/>

  <target name="init">
    <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build}"/>
  </target>

  <target name="compile" depends="init"
        description="compile the source " >
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src}" destdir="${build}"/>
  </target>

  <target name="dist" depends="compile"
        description="generate the distribution" >
    <!-- Create the distribution directory -->
    <mkdir dir="${dist}/lib"/>

    <!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
    <jar jarfile="${dist}/lib/Testing-${DSTAMP}.jar" basedir="${build}"/>
  </target>

  <target name="clean"
        description="clean up" >
    <!-- Delete the ${build} and ${dist} directory trees -->
    <delete dir="${build}"/>
    <delete dir="${dist}"/>
  </target>
</project>

It basically gives me this error

Code: Select all

BUILD FAILED
C:\Documents and Settings\xxxxxxxx\test\Testing\build.xml:20: 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\jre6"


Is their a certain command that I can put in the build.xml that allows me to set the path to the compiler,...etc
Thanks
User avatar
linuxfood
Member
Member
Posts: 38
Joined: Wed Dec 31, 2008 12:22 am

Re: ant script ?

Post by linuxfood »

Perhaps set JAVA_HOME environment variable to wherever you have Java installed?

Really, the error message tells you everything.

Edit: do you have the jdk? It's currently set to the jre.
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

Re: ant script ?

Post by Sam111 »

I have tried setting/creating JAVA_HOME variables in the system variables.
But it still gives me

Code: Select all

BUILD FAILED
C:\Documents and Settings\xxxxxxxxx\test\Testing\build.xml:20: 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\jre6"

What is this com.... class path issue am I suppose to include an external tools.jar file?

Thanks for any help I would really like to get this to work.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: ant script ?

Post by Combuster »

Edit: do you have the jdk? It's currently set to the jre.
read?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

Re: ant script ?

Post by Sam111 »

Yes, I have the jdk it is located at

Code: Select all

C:\Program Files\Java\jdk1.6.0_20\bin
When I run my java application in eclipses by clicking the run button.
It compiles and runs fine. But when I create a build.xml and click run as ant ,...etc it gives me the above error.


All I did is create a build.xml file and right clicked on ant build.
Then I got those errors

Is their something I am missing with creating ant scripts. I thought all you have to do is create the .xml and execute it is their some settings that need to be setup first?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: ant script ?

Post by Combuster »

do you have the jdk?
It is currently set to "C:\Program Files\Java\jre6"
Need I use colours? :-({|=


Edit: I pointed you at the required knowledge two years ago, and even now you're still missing the blatant obvious. You should really practice problem solving since your entire post history shows you can't.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

Re: ant script ?

Post by Sam111 »

Yes
That was it my mistake.

Is their away to use ant scripts at command line and not thru an IDE like eclispe.

For example if I created an ant script could I run it somehow at the command prompt?

Thanks
Post Reply