类路径问题,Head First servlet 书籍

发布于 2024-09-06 11:22:42 字数 454 浏览 3 评论 0原文

我正在通过 Head First 的 Servlet 和 JSP 进行学习,并完成第三章的作业。

在第 81 页,有一个 javac 调用:

>     %javac -classpath /Users/bert/Applications2/tomcat/common/lib/  
    servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java  

我不明白它想要做什么。书上说,common 之前的路径上的所有内容都应该适合我的特定系统,但我没有 common/lib 路径(据我所知)。我正在 ubuntu 9 上工作,我创建了以下目录结构来部署和开发本章讨论的 Web 应用程序,它们都没有 common/lib/ 路径。我在我的机器上哪里可以找到这个?

I'm studying via Head First's Servlets and JSPs, and doing the assignment on the third chapter.

On page 81, there's this javac call:

>     %javac -classpath /Users/bert/Applications2/tomcat/common/lib/  
    servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java  

I don't get what it's trying to do. The book says that everything on the path before common should be suited for my specific system, but I don't have a common/lib path (not that I know of). I'm working on ubuntu 9 and I have created the following directory structures for deployment and developing of the web app that the chapter talks about, neither of them has a common/lib/ path on them. Where can I find this on my machine?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

会发光的星星闪亮亮i 2024-09-13 11:22:42

您使用的是哪一版本的书? /common/lib 在 Tomcat 5.5 (Servlet 2.4) 中一直有效。从 Tomcat 6.x (Servlet 2.5) 开始,Servlet API 库就可以在 /lib 文件夹中找到。

Which edition of the book are you using? The /common/lib is true for until with Tomcat 5.5 (Servlet 2.4). Since Tomcat 6.x (Servlet 2.5) and on the Servlet API libraries are available in /lib folder.

唯憾梦倾城 2024-09-13 11:22:42

如果跟踪路径的其余部分,您将看到 common/lib 属于 Tomcat,在编译和打包 servlet 时,您将在该引擎上部署和运行 servlet。

我假设您已经下载并安装了 Tomcat

既然你说这本书调用了“common/lib”,那就告诉我这些例子是基于Tomcat 5.5的。 Tomcat 6.x(最新版本)使用“lib”而不是“common/lib”。

关键是您需要 servlet API JAR 才能成功编译。

If you trace the rest of the path, you'll see that common/lib belongs to Tomcat, the engine on which you'll deploy and run your servlet when it's compiled and packaged.

I'm assuming that you've downloaded and installed Tomcat.

Since you said the book called for "common/lib", that tells me that the examples are based on Tomcat 5.5. Tomcat 6.x, the latest version, uses "lib" instead of "common/lib".

The point is that you need the servlet API JAR in order to compile successfully.

我喜欢麦丽素 2024-09-13 11:22:42

如果您安装了 Tomcat 的打包版本,则应为:

  • 对于 Tomcat 5.5 /usr/share/tomcat5.5/common/lib/servlet-api.jar
  • /usr/share/tomcat6 Tomcat 6 的 /lib/servlet-api.jar

但我的建议是从 官网(如果你想坚持看书,就获取这本书的版本)并将其解压到你的主文件夹中(我把这种东西放在~/opt

If you installed a packaged version of tomcat, it should be:

  • /usr/share/tomcat5.5/common/lib/servlet-api.jar for Tomcat 5.5
  • /usr/share/tomcat6/lib/servlet-api.jar for Tomcat 6

But my recommendation would be to get a binary distribution of Tomcat from the official website (get the version of the book if you want to stick to the book) and to uncompress it in your home folder (I put this kind of stuff in ~/opt)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文