Search code examples
javaeclipsejarbuildpath

Eclipse projects vs build path


I am building a library which wraps some code around spymemcached client. This is called CacheClient. This is s simple Java project. I put the spymemcached.jar into its lib folder.

Here is how it looks like, also you can see the build path settings:

Library: CacheClient Project: cacheclient.jar

  • lib
    • spymemcached.jar

Java Build Path / Libraries Tab: spymemcached.jar - CacheClient/lib/spymemcached.jar

What I am doing is I am building a simple java web project which is using this library.

WebApp: ServiceWebApp Project: servicewebapp.war

  • WebContent
    • WEB-INF
      • lib
        • EMPTY

Java Build Path / Projects Tab: CacheClient

So, my Webapp's build path is set to using the CacheClient project. I copied the cacheclient.jar into tomcat's lib directory and deployed the ServiceWebApp.

When I run the web app, it fails as it says my CacheClient code is looking for the spymemcached classes (ClassNotFoundException).

I could solve this by putting spymemcached.jar into tomcat's lib directory but it would be great if there will be an other solution.

Any suggestion appreciated.

Thanks,


Solution

  • The simplest way of making the lib available in your web app would be to put the lib's jar to your WEB-INF/lib directory.

    If you don't want to do it manually, check this link about how this can be automated: Adding 3rd party jars to WEB-INF/lib automatically using Eclipse/Tomcat