ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Earle" <>
Subject RE: ClassLoading within <script> using javascript
Date Thu, 03 Jun 2004 03:59:50 GMT

Doah!  It was my IDE.  Netbeans was using a security policy when running ant 
in the IDE.

----Original Message Follows----
From: "Erik Earle" <#####>
Reply-To: "Ant Users List" <>
Subject: ClassLoading within <script>  using javascript
Date: Wed, 19 May 2004 20:50:22 -0400

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.


Is your PC infected? Get a FREE online computer virus scan from McAfeeŽ 

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

View raw message