Well, you can tell whether or not a class has been loaded from a JAR file – use Foo.class.getResource("Foo.class")
and see whether the returned URL begins with “jar:”
For example, take this program:
public class Foo {
public static void main(String[] args) {
System.out.println(Foo.class.getResource("Foo.class"));
}
}
Running it loading the file from the file system:
file:/C:/Users/Jon/Test/com/whatever/Foo.class
Running it from a jar file:
jar:file:/C:/Users/Jon/Test/foo.jar!/com/whatever/Foo.class