ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gordon Tyler <gordon.ty...@sitraka.com>
Subject Re: [OT] getting name of launch jar
Date Thu, 05 Dec 2002 22:54:55 GMT
Dominique Devienne wrote:
> Which kind of breaks down if the class is not loaded from the System class
> loader, but a child loader of it (or a child loader of a parent of the
> system loader), and if the class is loaded from a classes/ directory.

Indeed. That wasn't an issue for our particular case. The following may 
work for those situations:

String className = MyClass.class.getName();
URL myClassUrl = MyClass.class.getResource("/" + className.replace('.', 
'/') + ".class");
URL jarUrl = 
((JarURLConnection)myClassUrl.openConnection()).getJarFileURL();

I think.

> Nevertheless, I don't think
> it's the recommended way to do it. --DD

Why not? What recommends the getProtectionDomain method over this one?

Ciao,
Gordon

-- 
Gordon Tyler
Software Developer, R&D
Sitraka (now part of Quest Software)
"Performance is Mission Critical"


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


Mime
View raw message