0

When using java -cp path1:path2:path3 SomeClass to execute a class, is it possible to make java report the jar or class filename and pathname which it finds for each package imported in the class?

halfer
  • 19,471
  • 17
  • 87
  • 173
Tim
  • 88,294
  • 128
  • 338
  • 543

1 Answers1

1

No ... and partly yes.

No because "importing" is a compile time concept only. There is no need to import a class in order to use it, and an import statement doesn't actually mean that the class is actually used. Also, you don't import a package: you import classes from a package, or static members from a class.

Partly yes because the java -verbose:class option will log each class that gets loaded by the JVM.

And if you want to statically find all of the other classes that are directly referenced by a given class it is possible to get this by analyzing the classes .class file.

Stephen C
  • 669,072
  • 92
  • 771
  • 1,162