Java 编译给出关于 servlet 库的错误 [英] Java compilation gives errors about servlet libraries

查看:55
本文介绍了Java 编译给出关于 servlet 库的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译一个导入一些 servlet 库的简单类.由于我还没有将 tomcat 目录添加到类路径中,那么让系统知道在哪里可以找到在 tomcat/lib 文件夹中找到的 servlet 库的好方法是什么?

I am trying to compile a simple class that imports some servlet libraries. Since I have not added the tomcat directory to the classpath, what is the good practice way to let the system know where to look for the servlet libraries which are found in the tomcat/lib folder?

目前,系统只是给出这样的错误:

Currently, the system just gives errors like this:

ackage javax.servlet does not exist
[javac] import javax.servlet.ServletException;

推荐答案

如果您只想使用 java 提供的工具,则必须查看 javac 工具的 JavaDocs 并将所需的 jars 添加到类路径中手.

If you want to use only the java-provided tools, you will have to look at the JavaDocs for the javac tool and add the desired jars to the classpath by hand.

除非这是一项学习练习,并且您正试图以艰难的方式"做到这一点,否则我建议您查看 Maven、Ant 或您最喜欢的 IDE,因为它们在您未来的职业生涯中会更有用.

Unless this is a learning exercise and you are trying to do it the "hard way", I would recommend looking into Maven, Ant, or your favorite IDE, as they will be more useful in your future career.

这篇关于Java 编译给出关于 servlet 库的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆