Tuesday, August 14, 2007

Java : Find which class is in which jar file

It's a real pain!

You keep getting ClassNotDefined and you have hundreds of Jar files and it takes ages to manually search them all.

The solution is to use Jarscan.

There's also a web version on the same page.

So e.g.

java -jar jarscan.jar -dir C:\JBoss-4.0.5.GA -class SafeClone

returns (for JBoss):

searching these jarfiles now ....

===============================================
Found: SafeClone
Class: org.jboss.serial.objectmetamodel.safecloning.SafeClone
Package: org.jboss.serial.objectmetamodel.safecloning
Library Name: jboss-serialization.jar
Library Path: C:\JBoss-4.0.5.GA\client\jboss-serialization.jar
===============================================

===============================================
Found: SafeClone
Class: org.jboss.serial.objectmetamodel.safecloning.SafeClone
Package: org.jboss.serial.objectmetamodel.safecloning
Library Name: jbossall-client.jar
Library Path: C:\JBoss-4.0.5.GA\client\jbossall-client.jar
===============================================

===============================================
Found: SafeClone
Class: org.jboss.serial.objectmetamodel.safecloning.SafeClone
Package: org.jboss.serial.objectmetamodel.safecloning
Library Name: jboss-serialization.jar
Library Path: C:\JBoss-4.0.5.GA\server\default\lib\jboss-serialization.jar
===============================================

Search took: 10360 milliseconds.


Neat!

Enjoy!

No comments: