Load the class source location from Class getResource()
public class Main { public static void main(String args[]) { Class theClass = Main.class; java.net.URL u = theClass.getResource(""); System.out.println("This class (FromWhere) is located at : " + u); } }