One way I've heard of is to do something along the lines of:-

URL url = getClass().getResource( "/wicket/SomeWicketClass.class");

Now url is something like

jar:file:/path/to/the/jar!/wicket/SomeWicketClass.class

Now you have to simply strip off the !/wicket/... part and replace
with !/META-INF/MANIFEST.MF
then
Manifest manifest = new Manifest(new URL(manifestPath).openStream());

(Something like that, anyway...)

On 07/03/06, Martijn Dashorst <[EMAIL PROTECTED]> wrote:
> Basically the way Johan said is the way we retrieve the version of our own
> application.
>
> Our own application tries to retrieve the version number of the war archive,
> so that is a different usecase.
>
> Martijn
>
>
>
> On 3/7/06, Maurice Marrink <[EMAIL PROTECTED]> wrote:
> > Codesource should never be null, if you class is in a jar file,
> > codesource points to the jar.
> > else it might point to a directory where your class files can be found
> > (or in subdirs thereof). if none of the above is available it will
> > point to the classfile itself.
> >
> > But perhaps Martijn can tell you how he did it, i know he did it for
> > our project but can't seem to find where.
> >
> > Maurice
> >
> > On 3/7/06, Joni Suominen < [EMAIL PROTECTED]> wrote:
> > > On Tue, 2006-03-07 at 10:27 +0100, Juergen Donnerstag wrote:
> > > > Do you know how to access that information?  How do you get the jar
> > > > file name a specific class has been loaded from?
> > >
> > >
> getClass().getProtectionDomain().getCodeSource().getLocation()
> gives you
> > > the location where the class was loaded from. I don't know in which
> > > situations the CodeSource may be null, though.
> > >
> > > Joni
> > >


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to