Page 1 of 1

ant script ?

Posted: Mon Dec 20, 2010 4:22 pm
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

Re: ant script ?

Posted: Mon Dec 20, 2010 4:32 pm
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.

Re: ant script ?

Posted: Tue Dec 21, 2010 9:21 am
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.

Re: ant script ?

Posted: Tue Dec 21, 2010 9:31 am
by Combuster
Edit: do you have the jdk? It's currently set to the jre.
read?

Re: ant script ?

Posted: Tue Dec 21, 2010 9:36 am
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?

Re: ant script ?

Posted: Tue Dec 21, 2010 9:44 am
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.

Re: ant script ?

Posted: Tue Dec 21, 2010 10:26 am
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