Created
October 9, 2013 10:40
-
-
Save kofemann/6899329 to your computer and use it in GitHub Desktop.
find from which jar some class is taken. Example: $ java -cp .:/$CLASSPATH find_jar org.slf4j.Logger
file:/xxxx/classes/slf4j-api-1.7.5.jar
$
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.security.CodeSource; | |
public class find_jar { | |
public static void main(String[] args) throws Exception { | |
if (args.length != 1 ) { | |
System.err.println("Usage: find <class name>"); | |
System.exit(1); | |
} | |
Class c = Class.forName(args[0]); | |
CodeSource codeSource = c.getProtectionDomain().getCodeSource(); | |
System.out.println(codeSource.getLocation()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment