Check if jar file is loaded? Check if jar file is loaded? unix unix

Check if jar file is loaded?


I think I have seen which jars are open on startup in one of Tomcat log files. If not I could think about two possible alternatives:

  1. Add -verbose:class to JAVA_OPTS in Tomcat startup script. It should print classes as they're loaded by JVM (lots of output). Grep log file (or stdout) to find if classes from your jar are listed
  2. Use Linux lsof command to see files opened by the Tomcat process.


Jars aren't really "loaded on startup". But Tomcat's system class loader is loading classes from those jars. You can check if some class from the jar is available either:

  • by trying to load that class from your code, e.g. getClass().getClassloader().loadClass(className)
  • by trying to load class as a resource, e.g. getClass().getResource("/" + className.replace('.', '/') + ".class")

In second case you should have name or your jar file in the url returned by getResource().