It's a sticky problem.
There are tools that can trace static dependencies, but it's virtually impossible to track dynamic dependencies.
If you are using
Maven to build your WAR, there are tools that can at least determine what jars claim other jars as dependencies, and I'm presuming that other tools such as Ant/Ivy may have similar capabilities.
Knowing jar dependencies isn't as fine-grained as knowing actual class dependencies, but it's good enough for most purposes.
As far as overhead goes, there may be some RAM consumed/cached for the indexes of classes not loaded, but it's not likely to be a major component of the overall memory usage.