This must be a very basic question for Java developers, but what is the best way to find the appropriate jar file given a class name?
For example, give
Given your comment on attempting to handle dependencies, what I would do is focus on which libraries you are using. Knowing this, you will know what jars have to be on the classpath, and you can pay attention to that. There are also dependency management builders (Maven and Ant being two popular ones) that can package up projects with their dependencies inside. However, in the end, it is up to the developer to know which dependencies they have, and to pay attention to the requirements for those dependencies. This is one reason why using an IDE like Eclipse, and build tools like Maven or Ant are so nice in large projects, as when you have 20 dependencies for a project, that can become pretty unmanageable.
Try findjar.com. If it's in the public domain, you should get it. There's alos mavenjava.com (but that site seems to be down)
locate .jar | xargs grep com.ibm.websphere.security.auth.WSSubject
You could try services like:
Or
Or
PS: Jarhoo has teamed up with Javacio.us to provide 100,000 Java developers with free access to Jarhoo via links integrated with their Google search results. Subscription to Javacio.us is free and open to anyone with a Google account. For more information, please visit the Jarhoo offer page at Javacio.us.
There is no "official" Java way to do this AFAIK.
The way I usually hunt for it is to use find and jar to look through all jar files in a given tree.
> find . -name \*.jar -print -exec jar tf {} oracle/sql/BLOB.class \;
./v2.6.1/lib/csw_library.jar
./v2.6.1/lib/oracle_drivers_12_01.jar
oracle/sql/BLOB.class
If you're on Windows and don't want to install Cygwin, then I suppose you would have to write a batch script to locate the jar files.
In windows powershell you can use this command. It list all the JAR files it encounters, but it has an extra line that's very easy to spot where it also finds your class.
Get-ChildItem -recurse -Filter *.jar | Foreach {echo $_.fullname; c:\somepath\JDK\BIN\jar tvf $_.fullname | Select-String -pattern "Cabbages.class"}