Java 编译给出关于 servlet 库的错误

编程入门 行业动态 更新时间:2024-10-25 12:20:42
本文介绍了Java 编译给出关于 servlet 库的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试编译一个导入一些 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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 03:32:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1389363.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   Java   servlet

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!