ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Earle" <erikea...@hotmail.com>
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" <user@ant.apache.org>
To: user@ant.apache.org
Subject: ClassLoading within <script>  using javascript
Date: Wed, 19 May 2004 20:50:22 -0400

I have a file stucture like so:

./build.xml
./lib/foo.jar

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 
happen.

The following would be ideal BUT throws an  AccessControlException

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

    importPackage(java.lang, java.util, java.io, java.net);
    importPackage(Packages.org.apache.tools.ant);
    importPackage(Packages.org.apache.tools.ant.taskdefs);

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

    loader = new URLClassLoader(urls);

    c = loader.loadClass( cName, true );
]]>
</script>


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


anyone?

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfeeŽ 
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message