java 将 jar 文件安装到 Tomcat Web 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3868843/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 03:46:18  来源:igfitidea点击:

Installing jar file to Tomcat web application

javajsptomcatjar

提问by Dominic Bou-Samra

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

如何将第 3 方 JAR 文件安装到我的 tomcat Web 应用程序?

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

有特定的文件夹吗?我试过 WEB_INF/lib

回答by duffymo

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.

如果 Tomcat 上的所有应用程序都需要该 JAR,如果您使用的是 Tomcat 6.x 或更高版本,则放置它的位置将是 /lib,如果它是 5.x 或更低版本,则放置它的位置将是 /server/lib。

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

如果您的应用只需要第 3 方 JAR,请将其放在 WEB-INF/lib 中。

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

我希望您将应用程序打包为 WAR 文件。

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.

我建议您在继续之前阅读更多有关 Tomcat 和 CLASSPATH 的信息。

import com.google.api.translate;

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

对我来说,这看起来不像是合适的 Java。不应该是:

import com.google.api.translate.*;

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

包含这些类的 JAR 的名称是什么?你在哪里找到它?

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

看起来您想以某种方式使用 Google 的翻译 API。