简体   繁体   English

无法引用 servlet-api.jar

[英]Can't reference servlet-api.jar

I've moved my Java stuff to a new Windows 10 machine, using jdk1.8.0_291.我已经使用 jdk1.8.0_291 将我的 Java 东西移到了新的 Windows 10 机器上。 I've installed C:\xampp through which I'm using Tomcat.我已经安装了 C:\xampp,通过它我正在使用 Tomcat。

My problem is that I can't get the main programs to compile.我的问题是我无法编译主程序。

The header lines are: header 线是:

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;


public class AddressServlet extends HttpServlet {

and I get the error: "javax.servlet does not exist"我得到错误:“javax.servlet 不存在”

Elsewhere, I've seen that javax.servlet is in servlet-api.jar in the tomcat/lib folder.在其他地方,我看到 javax.servlet 位于 tomcat/lib 文件夹中的 servlet-api.jar 中。 I've tried adding this to the CLASSPATH variable as C:\xampp\tomcat\lib\servlet-api.jar but it didn't work.我尝试将它作为 C:\xampp\tomcat\lib\servlet-api.jar 添加到 CLASSPATH 变量中,但它没有用。 I've even copied the jar file into the same folder as the code, but the error persists.我什至将 jar 文件复制到与代码相同的文件夹中,但错误仍然存在。

Does anybody know what I'm doing wrong?有人知道我做错了什么吗? Many thanks.非常感谢。

It's all ended happily.这一切都以愉快的方式结束了。 I just needed a reboot.我只需要重新启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM