You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Longie <lo...@esatclear.ie> on 2005/01/25 17:56:19 UTC

Packages + Ant

Hello,

I am having a problem running a jar file which worked before i created the
different package directories.

The directory looks like this;

root
 |
 |- - - src
 |	 |
 |	 |----ie
 |		|--- comp
 |			|---tool [all *.class]
 |
 |- - - images [all *.gif]
 |
 |- - - ant-files [ant.jar]
 |
 |- - - classes
 |	 |
 |	 |----ie
 |		|--- comp
 |			|---tool [all *.java]
 |
 |- - - lib [ ProjectName.jar]
 |
 |- - - build.xml
 
My build.xml looks like this;

<?xml version="1.0" encoding="UTF-8"?>

<project name="xxxx" basedir="." default="compile">

    <property name="src.dir" value="src"/>
    <property name="classes.dir" value="classes"/>
    <property name="images.dir" value="images"/>
    <property name="ant-package" value="ant.jar"/>
    <property name="ant.dir" location="ant-files" />
	  
	
    <target name="compile" description="Compiles the Task">
        <mkdir dir="${classes.dir}"/>
  <javac debug="on" deprecation="on" srcdir="${src.dir}"
classpath="${ant-package}" destdir="${classes.dir}" />
    </target>

    <target name="jar" description="JARs the Task" depends="compile">
        <jar destfile="${ant.project.name}.jar" basedir="${classes.dir}">
        <fileset dir="." includes="ant-files/*.jar"/>
        <fileset dir="." includes="${images.dir}/**"/>
        </jar>
    </target>

  <target name="run" depends="jar">
    <java classname="AntTool" classpath="${ant.project.name}.jar;
${ant-package}" fork="true"/>
  </target>

I have two problems - one is that the compile target works fine - however
when i execute the run target i get 
"NoClassDefFoundError: org/apache/tools/ant/taskdefs/Ant

which is being caused by a class in the classes directory that looks like

import org.apache.tools.ant.taskdefs.Ant;
import org.apache.tools.ant.taskdefs.Property;

import java.io.File;

public class HelloWorldTwo extends Ant{

	private File dir;

  public HelloWorldTwo() {

  	System.out.println("HelloWorldTwo called");

  	}

When i remove the extends Ant from the file it works fine. Before i created
the subdirectories this worked fine.

Is it a build.xml error or a syntax error when calling either javac or java.


Please - need help on this.

Regards,

John



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org