question 13

Posted Thursday, September 03, 2009 by SacrosanctBlood in

How do you find absolute path of the Class currently in execution? The
Class may be a part of a jar, in which case, the path to the jar file
location is needed on individual systems.



1 comment(s) to... “question 13”

1 comments:

SacrosanctBlood said...

The path to the jar file that is actually having the class which is
executed can be found out by below snippet of code.



public class TestOne{

public static void main(String[] args) {

Class cls = TestOne.class;

ProtectionDomain domain = cls.getProtectionDomain();

CodeSource source = domain.getCodeSource();

URL url = source.getLocation();

System.out.println(url);

}

}



Post a Comment