Where are the class files?

K

kaopelt

How can I find out where the class files are installed in a
programmtic way?

Thanks,
Menlo
 
O

Oliver Wong

How can I find out where the class files are installed in a
programmtic way?

Classes might not come from files: they may be loaded from the
network, or dynamically generated.

- Oliver
 
T

Tom Hawtin

How can I find out where the class files are installed in a
programmtic way?

clazz.getProtectionDomain().getCodeSource().getLocation()

You might not get meaningful information from this.

Tom Hawtin
 
A

Andrew Thompson

How can I find out where the class files are installed in a
programmtic way?

Why (do you think you need to know)? What ability
are you attempting to bring to the end user, by identifying
where the class files reside?
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

How can I find out where the class files are installed in a
programmtic way?

Try something like:

private String getPath(Class cls) {
String cn = cls.getName();
String rn = cn.replace('.', '/') + ".class";
String path =
getClass().getClassLoader().getResource(rn).getPath();
int ix = path.indexOf("!");
if(ix >= 0) {
return path.substring(0, ix);
} else {
return path;
}
}

Arne
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top