ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject RE: [OT] getting name of launch jar
Date Thu, 05 Dec 2002 23:03:51 GMT
Just seems cleaner to me that's all. I'm there are cases where both methods
break down anyhow (make your own class on the fly with BCEL and load it).


PS: You still assume the class is coming from a JAR. I'd have to check
myClassURL to see if it's file: based, http: based, jar: based, etc... And
you'd have to deal with inner classes in a.B$C, etc... It gets complex.

-----Original Message-----
From: Gordon Tyler [] 
Sent: Thursday, December 05, 2002 4:55 PM
To: Ant Users List
Subject: Re: [OT] getting name of launch jar

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 = 

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?


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

View raw message