Java – How to set a Tomcat webapp classpath

classpathjavatomcat

Hello I have a webapp in Tomcat server on linux

I need to be able to tell it in what order to load the jars located in WEB-INF/bin.
I tried to set it up in the META-INF/MANIFEST.MF under Class-Path but it didn't work, and I've searched the web for a solution and did not find any.

(My project is not inside a war file)

(The solution to chane the jar filename to "aaaaaaaRealName.jar" is unacceptable)

(I'm using Tomcat 7 (I think its v7.0.27))

Ido

Best Answer

The tomcat loads jars in the following order (extract from here: http://tomcat.apache.org/tomcat-8.0-doc/class-loader-howto.html):

  • bootstrap (JRE/lib/ext folder)
  • system (can't used to add yours)
  • webapp libraries (first WEB-INF/classes, then WEB-INF/lib)
  • common libraries (check the common.loader property , then tomcat instance/lib, then common tomcat folder/lib)

So if you want to specify the order, just put the jars in the right place.