如何让Eclipse识别Java EE jar文件,以便Servlets可以编译? [英] How do you make Eclipse recognize Java EE jar files so Servlets can compile?
问题描述
我正在设置Eclipse的Java EE版本来编译Servlets。我有一个问题,Eclipse说HttpServlet无法解析,因为它无法找到Java EE jar文件。
I am setting up my Java EE version of Eclipse to compile Servlets. I have the problem where Eclipse says "HttpServlet" cannot be resolved because it can't find the Java EE jar files.
我使用的是Windows XP。我已经启动并运行了Tomcat 6.0。我认为最简单的解决方案是链接到Tomcat安装中的servlet-api.jar文件。
I am using Windows XP. I already have Tomcat 6.0 up and running. I think the easiest solution would be to link to the servlet-api.jar file in the Tomcat installation.
我将它添加到Windows CLASSPATH环境变量中。现在它看起来像这样:
.; C:\Program Files\Java\jre1.6.0_04\lib\ext\QTJava.zip; C:\Program Files \ Amaache Software Foundation \ Tomcat 6.0 \lib \servlet-api.jar
I added it to the Windows CLASSPATH environment variable. Now it looks like this: .;C:\Program Files\Java\jre1.6.0_04\lib\ext\QTJava.zip;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar
这不起作用。我做错了什么?
That didn't work. Am I doing something wrong?
什么是最好的解决方案?
What is the best solution?
推荐答案
您可以将servlet-api.jar文件添加到项目属性中。
从项目层次结构中右键单击项目名称 - >属性 - > Java构建路径 - >库选项卡。
从那里,将servlet-api.jar添加为外部jar文件。
You can add the servlet-api.jar file into the project properties. From the project hierarchy right click the project name->properties->Java build path->Libraries tab. From there, add the servlet-api.jar as an external jar file.
这篇关于如何让Eclipse识别Java EE jar文件,以便Servlets可以编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!