Officially you can't, but a few hacks can help you out. One of them uses ProtectionDomain, search Javaworld.com for the article. The other one uses the fact that with most class loaders you can use the .class file itself as a resource. For instance, try this:
If the class file is located in a JAR file cut off the leading "jar:" and everything after the !. What remains is a URL to the JAR file. If the class file is located in a folder cut off the full class name with / instead of . (e.g. java/lang/String.class).
To convert the remaining URL to a File the following code can help you:
That will only work if the remainingString is a URL with protocol "file".