I was trying to building a java project with a run function. Problem is, the build file is located at the base directory and file with the main method is in the /contents/username/ subdirectory - I can't seem to properly call the file even though when I run Ant compile, the .java with the main method is compiled without a problem

<project name="build" default="compile">
    <target name="compile" depends="clean">
        <javac srcdir="." includeantruntime="false"/>

    <target name="clean">
            <fileset dir="." includes="**/*.class"/>
            <fileset dir="." defaultexcludes="no" includes="**/*~"/>
        <delete dir="META-INF" failonerror="false"/> 

    <target name="run" depends="compile, who">
        <java classname="Driver" classpath="./contents/username" fork="yes"/>

    <target name="who">
        <echo message="Written by ****, is that a good thing?"/>

    <target name="jar">
        <jar destfile="./username.jar"> 
            <fileset dir="." includes="**/*.java, build.xml"/>


I'm not sure if it's polite to post my own solution before I hear from anyone else, but I found a solution that works. Replace line 15 with:

<java classname="contents.username.Driver" fork="yes"/>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.