i.e. I need to get path of the directory from where my classes are loaded.
Asked
Active
Viewed 53 times
0
-
Launch your app with `java -verbose:class`. Make sure you have enough buffer in your terminal, it is very verbose. Or redirect to a file or use grep for easier searching. – StephaneM Sep 24 '14 at 08:15
-
@StephaneM, from within the program. – user626528 Sep 24 '14 at 08:16
-
1The last answer from this thread: http://stackoverflow.com/questions/11613988/how-to-get-classpath-from-classloader may be what you want. – StephaneM Sep 24 '14 at 08:22
-
@StephaneM, why don't make it an answer? – user626528 Sep 24 '14 at 08:29
1 Answers
0
The last answer from this thread: How to get classpath from classloader? may be what you want:
ClassLoader cl = ClassLoader.getSystemClassLoader();
URL[] urls = ((URLClassLoader) cl).getURLs();
for (URL url: urls) {
System.out.println(url.getFile());
}