ShowPathToClass.java

Download ShowPathToClass.java

 1: // This utility tells you the filename of any class.  Example:
 2: //  java ShowPathToClass java.lang.Integer
 3: //
 4: // Written 11/2020 by Wayne Pollock, Tampa Florida USA
 5: 
 6: public class ShowPathToClass {
 7:     public static void main ( String[] args ) {
 8:         if ( args.length == 0 ) {
 9:             System.out.println(
10:                 "Usage: ShowPathToClass <fully-qualified class name>");
11:             return;
12:         }
13:         String className = args[0].replace(".", "/");
14:         className = className + ".class";
15:         ClassLoader cl = ShowPathToClass.class.getClassLoader();
16:         System.out.println( cl.getResource(className) );
17:     }
18: }