Hi there

I've made this cool patch system for upgrading between versions of a
system. I want the patch to be an executable jar fil containing a jar
file with the patch upgrade files, an ant build file, and an AntLoader
class I've created.

The jar file looks like this:

test.jar
  |--patch.jar
  |--build.xml
  |--no
      |--nhst
            |--cpc
                 |--AntLoader.class

test.jar also contains a manifest for loading AntLoader.class when
running java -Xbootclasspath/a:${CLASSPATH} -jar test.jar.

This works fine. Ant is loaded and running. BUT it says that it can't
find build.xml. That is because build.xml is inside the jar file, and
not directly in the directory structure.

Is there a way to make the org.apache.tools.ant.Main class look for the
build.xml file inside the jar file which is also loading the ant
package, instead of looking for it in the same directory as test.jar was
executed from?

Brgds

Jakob

My AntLoader.java class looks like this:

############################################
package no.nhst.dnno.cpc;

import org.apache.tools.ant.Main;

/**
 * <code>AntLoader</code> is a class for executing ant from inside
 * a java application. We are using it as a tool for executing ant
 * from inside a jar archive file.
 *
 * @author Jakob Vad Nielsen <[EMAIL PROTECTED]>
 * @version $Date: 2002/01/28 18:14:47 $
 */
public class AntLoader {

    /**
     * Run Ant with the parameters given as a string array.
     * Ant itself handles error outputs.
     * @param args Arguments that should be passed on to Ant.
     */
    public static void main( String[] args ) {
        try {
            org.apache.tools.ant.Main.start( args, null, null );
        } catch ( java.lang.NoClassDefFoundError e ) {
            String lf = java.lang.System.getProperty( "line.separator"
);
            System.err.println( "ERROR: Requires ant.jar in runtime
environment (CLASSPATH)."+lf);
            System.err.println( "On unix systems type:"+lf+"'export
CLASSPATH=$CLASSPATH:<path to ant.jar>'" );
            System.err.println( "Example: export
CLASSPATH=$CLASSPATH:/opt/ant/lib/ant.jar"+lf );
            System.err.println( "On windows systems type:"+lf+"'set
PATH=%PATH%;<path to ant.jar>'" );
            System.err.println( "Example: set
PATH=%PATH%;c:\\ant\\lib\\ant.jar" );
        }
    } // runAnt
    
} // class AntLoader
############################################




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to