ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Earle" <>
Subject ClassLoading within <script> using javascript
Date Thu, 20 May 2004 00:50:22 GMT
I have a file stucture like so:


foo.jar is NOT on my classpath when I invoke ant.

I want to be able to dynamically load classes from foo.jar or append the jar 
to the classpath in a task or something.  I haven't been able to make it 

The following would be ideal BUT throws an  AccessControlException

<property name="jarfile" location="${basedir}/lib/foo.jar"/>
<script language="javascript">

    importPackage(java.lang, java.util,,;

    file = new File(jarfile);
    urls = java.lang.reflect.Array.newInstance(,1);
    urls[0] = file.toURL();

    loader = new URLClassLoader(urls);

    c = loader.loadClass( cName, true );

I've tried other end-arounds but no love.


Get 200+ ad-free, high-fidelity stations and LIVE Major League Baseball 
Gameday Audio!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message