Skip to content

Instantly share code, notes, and snippets.

@claytantor
Created November 29, 2015 07:09
Show Gist options
  • Save claytantor/9bd3e94b164e63a318a4 to your computer and use it in GitHub Desktop.
Save claytantor/9bd3e94b164e63a318a4 to your computer and use it in GitHub Desktop.
A way to determine current filesystem location of executed class from the code of this class, in runtime, given that it's executed using java command.
final File f = new File(
MyClass.class
.getProtectionDomain()
.getCodeSource()
.getLocation().getPath());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment