Check if the jar file is loaded?

I have a custom jar file in tomcat lib / folder. From my knowledge, any jar file in this folder will be loaded on startup.

Is there anyway I can check if a specific jar file is loaded or not?

I am running tomcat-6.0.35.A on unix rhel5.


source to share

2 answers

I think I've seen which jars are opened at startup in one of the Tomcat log files. If it weren't for me, I could think of two possible alternatives:

  1. Add -verbose:class

    in JAVA_OPTS

    Tomcat startup scripts. It should print the classes as they are loaded by the JVM (a lot of output). Grep log file (or standard stdout

    ) to find if classes are listed from your jar
  2. Use the Linux lsof command to view the files opened by the Tomcat process.


The boxes are not actually loaded at startup. But Tomcat classloader loads classes from these jars. You can check if any class is available from the jar:

  • trying to load this class from your code eg. getClass().getClassloader().loadClass(className)

  • trying to load a class as a resource like getClass().getResource("/" + className.replace('.', '/') + ".class")

In the second case, you must have the name or your jar file in the url returned getResource()




All Articles