Q: URL of Class?

M

Mark

Is ClassLoader.getSystemResource the only way that I can determine
where in the filesystem a particular Class was loaded from (assuming
classes are coming from the filesystem)? In my application I have a
need to know where a class came from.

The reason I ask is that I have a specialized classloader and wish to
know whether I have to override getSystemResource. Or is there another
way I can determine the URL given an instance of Class?

Many thanks in advance for any useful answers!
 
J

Jean-Francois Briere

Hold your breath:

getClass().getProtectionDomain().getCodeSource().getLocation()

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,241
Latest member
Lisa1997

Latest Threads

Top