views:

30

answers:

1

How do I install a 3rd party JAR file to my tomcat web application?

I have placed it in every folder I can think of, and am referencing it like:

import com.google.api.translate;

Is there a particular folder? I have tried WEB_INF/lib

+2  A: 

If all apps on Tomcat need that JAR, the place to put it would be /lib if you're using Tomcat 6.x or higher and /server/lib if it's version 5.x or lower.

If only your app needs a 3rd party JAR, put it in WEB-INF/lib.

I hope you're packaging your app as a WAR file.

I have placed it in every folder I can think of

I'd recommend reading a bit more about Tomcat and CLASSPATH before you proceed.

import com.google.api.translate;

This doesn't look like proper Java to me. Shouldn't that be:

import com.google.api.translate.*;

What is the name of the JAR containing those classes? Where did you find it?

Looks like you want to use Google's translate API somehow.

duffymo
Do I not need to add it to my ant build xml files etc?
Dominic Bou-Samra
If you're using Ant to compile and package your app, you need to make sure that the JAR is in the Ant CLASSPATH and gets copied into your WAR file's WEB-INF/lib.
duffymo
It's in the ant classpath, but no go :( Must be making an error somewhere.
Dominic Bou-Samra
I asked findjar.com to find a JAR with that class in it, but no go.
duffymo
Looks like the google-api-translate-java-0.92.jar at http://code.google.com/p/google-api-translate-java/
JoseK
Turns out I needed to reference it in my ant build.xml.
Dominic Bou-Samra