Created
May 3, 2010 08:26
-
-
Save bhattisatish/387873 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Provides the URL for the location of your executing code for a given class. | |
ProtectionDomain protectionDomain = MyClass.class.getProtectionDomain(); | |
URL location = protectionDomain.getCodeSource().getLocation(); | |
location.toExternalForm(); | |
OR | |
File codeLoc = new File(protectionDomain.getCodeSource().getLocation().getFile()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment