ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Inger <ma...@sedonacorp.com>
Subject Re: Windows cmd line length problems
Date Mon, 15 Oct 2001 19:46:57 GMT
If this is indeed, a problem with the command line length,
then try to refer to the files with a relative path if you
can.   in worst case, you can write your own customer 
classloader that would look for some system property, and
then look in the directory indicated by that, and load all
the classes that you need from that classloader.  It's a
pain because you will have to explicitly have to load
each class, and it's a coding solution, but nonetheless,
it will work.  I don't claim to be an expert on classloaders,
and maybe someone here could help you more on how to
bootstrap the vm so you can use this classloader as the
default (note that it uses the system classloader as
it's parent, so it will pay attention to the system
CLASSPATH if it can't directly find the class in the
specified directory)



------- Start DirectoryClassLoader.java
import java.io.File;
import java.util.ArrayList;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

public class DirectoryClassLoader extends ClassLoader
{
    private String directory;
    private URLClassLoader loader;

    public DirectoryClassLoader(String directory)
    {
        this(directory, ClassLoader.getSystemClassLoader());
    }

    public DirectoryClassLoader(String directory, ClassLoader parent)
    {
        super(parent);

        ArrayList urls = new ArrayList();

        this.directory = directory;

        if (directory != null)
        {
            File f = new File(directory);
            
            if (f.exists() && f.isDirectory())
            {
                File children[] = f.listFiles();
                for (int i=0;i<children.length;i++)
                {
                    try
                    {
                        urls.add(children[i].toURL());
                    }
                    catch (MalformedURLException e)
                    {
                    }
                }
            }
        }

        this.loader = new URLClassLoader((URL[])(urls.toArray(new URL[0])), getParent());

    }

    public Class loadClass(String name)
        throws ClassNotFoundException
    {
        return loader.loadClass(name);
    }

    public static void main(String args[])
        throws Exception
    {
        String dir = System.getProperty("app.jar.directory");
        DirectoryClassLoader dcl = new DirectoryClassLoader(dir);
        Class c = dcl.loadClass("DirectoryClassLoader");
        System.out.println(c.getName());
    }
}

On Mon, 2001-10-15 at 14:35, Jesse Vitrone wrote:
> I'm sure people have run into this problem before...is there a good
> solution?
> 
> We have a build.bat file which creates the needed classpath, then passes
> that on to Ant to do the build.  We have a lot of jars that need to be
> in the classpath.  Recently, we needed to add another jar, and now the
> build.bat fails because the line length is too long.
> 
> Are we not using Ant right?  Is there a way around this problem that
> we're having?  I would think that people have run into this problem
> before.
> 
> Thanks in advance,
> 	Jesse
-- 
Matt Inger (matt.inger@sedonacorp.com)
Sedona Corporation
455 S. Gulph Road, Suite 300
King of Prussia, PA 19406
(484) 679-2213
"Self-respect - the secure feeling that no one,
 as yet, is suspicious." -H.L. Mencken 


Mime
View raw message