Skip to content

Instantly share code, notes, and snippets.

@abhisheksharma1
abhisheksharma1 / RunTime.java
Created March 7, 2018 09:50
Check which jar is used at runTime
Class theClass = Cluster.class;
// Find the path of the compiled class
String classPath = theClass.getResource(theClass.getSimpleName() + ".class").toString();
System.out.println("Class: " + classPath);
// Find the path of the lib which includes the class
String libPath = classPath.substring(0, classPath.lastIndexOf("!"));
System.out.println("Lib: " + libPath);