reversed(top()) code tags rss about

How to share code among several Web-service applications written in Java

November 9, 2012
[howto] [programming] [java] [eclipse] [jar] [web-service]

Some time ago I’ve spent a lot of time trying to figure out how one can share common parts of code in two Web-services running in Apache Tomcat. What I wanted is to move several packages to a separate Eclipse project and refer to it from several other projects. Somewhere on the Web a nice list of options to achieve this was found. All (or almost all) of them were connected with the Classpath settings pane in the project options. But unfortunately no matter what Classpath options I set, it didn’t work. I’ve also tried exporting project with the common functionallity to a jar file and linking to it from other project. That didn’t work either, that jar file wasn’t deployed to Tomcat server.

So after spending a lot time on this, I finally made it work and forget about the issue. I just investigated what I did to make it work and decided to document it. The answer is simple as “just put jar file to the lib directory of Tomcat”. And that’s it, don’t forget to regenerate it after making changes in shared code.