Discovering the JAR file associated with a specific class: A guide

I’m interested in determining the external classes and methods that are utilized by the classes within a JAR file. This compact command-line utility is designed to scan for the usage of classes or packages within JARs or directories that contain classes.

Question:

I need assistance in determining the JAR file that contains a specific class. Any help would be appreciated!


Solution 1:


Take a glance at
jarfinder
as it can provide assistance.
“””.


Solution 2:

  • Class Locator an eclipse plugin which may help you, if you are using eclipse.

  • FindJar.com to find it from internet.

  • Also
    jboss tattletale


Solution 3:

In Eclipse, the search for targets can be done by using the shortcut ctrl+shift+t. Simply provide the class name and it will display the relevant jars. It is important to note that these jars need to be attached to the build paths.


Solution 4:

If you require the runtime location of a class, you can attempt the following:

obj.getClass().getProtectionDomain().getCodeSource().getLocation()

However, it should be noted that

getCodeSource

may yield

null

for certain classes, such as those from

rt.jar

.

Frequently Asked Questions