Monday, November 16, 2015

File path from Class Relative

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());
view raw Filepath.java hosted with ❤ by GitHub
http://stackoverflow.com/questions/11747833/getting-filesystem-path-of-class-being-executed

No comments: