1

If an exception occurs due to a missing jar file, then is there any way to back track and find out the missing jar file?

Suppose the following exception:

java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod

which is caused by missing commons-httpclient-3.0.1.jar file.

Leo
  • 5,017
  • 6
  • 32
  • 55
  • See [this](http://stackoverflow.com/a/1500166/1015327) answer, for example. – JimmyB Apr 14 '15 at 10:17
  • Think [this answer](http://stackoverflow.com/a/1983870/225503) will solve your problem. Also, [this other one, showing how to print where all classes are loaded from](http://stackoverflow.com/a/947216/225503) could help – Diego Freniche Apr 14 '15 at 10:41

3 Answers3

1

There is no way you can find which jar have which class file. You can only find out package structure of missing class like org/apache/commons/httpclient based on that if you can guess which jar is missing.

And its hard because any jar can have classes in any package structure.

Neeraj Jain
  • 7,643
  • 6
  • 34
  • 62
Sumit Singh
  • 15,743
  • 6
  • 59
  • 89
  • The class loader doesn't care about JAR files. It sees them as part of the directory structure of the class path. JARs are just compressed file systems. So Sumit is absolutely correct. – Dan Apr 14 '15 at 10:19
1

I use findjar (http://findjar.com/index.x) to know which jar will contain a specific class based on which i will investigate whether jar is in classpath or not

vasa.v03
  • 147
  • 2
  • 12
0

As was meant above, java compiler gives us info about missing classes, not jars. You can try find jar, containing particular class by its short or fully specified name, for example org/apache/commons/httpclient/HttpMethod, using web resources, as jar-download.com, findjar.com or search.maven.org

IvanMikhalka
  • 184
  • 10