[英]There is no javax.servlet package in my JDK
I am following Head First: Servlet and JSP
and I was writing my first Servlet. 我遵循的是
Head First: Servlet and JSP
并且正在编写我的第一个Servlet。
I tried to compile it using command line and I got an error that package javax.servlet
does not exist. 我尝试使用命令行对其进行编译,但出现错误消息
package javax.servlet
不存在。
So far, I have set the JAVA_HOME
variable to the value: C:\\Program Files\\Java\\jdk1.7.0_11
and the PATH
variable also to C:\\Program Files\\Java\\jdk1.7.0_11\\bin
到目前为止,我已经将
JAVA_HOME
变量设置为以下值: C:\\Program Files\\Java\\jdk1.7.0_11
,并且PATH
变量也设置为C:\\Program Files\\Java\\jdk1.7.0_11\\bin
How do I get the javax.servlet
package? 如何获得
javax.servlet
包?
Also, I have installed JDK 7 update 11
after the applet bug that was being exploited. 此外,在被利用的applet错误之后,我还安装了
JDK 7 update 11
。
I have both JDK Update 11
and JDK Update 9
installed. 我同时安装了
JDK Update 11
和JDK Update 9
。
Should I get rid of Update 9
or is it not needed ? 我应该摆脱
Update 9
还是不需要?
Operating System: Windows 7 Home Premium 32 bit 操作系统: Windows 7 Home Premium 32位
What I also tried: 我还尝试了什么:
javac -cp .;D:\\Program Files\\apache-tomcat-7.0.35-windows-x86\\apache-tomcat-7.0.35\\lib\\servlet-api.jar Ch1servlet.java
I tried both forward slash AND backward slash. 我尝试了正斜线和反斜线。 In both the cases I got an invalid flag error.
在这两种情况下,我都收到无效的标志错误。
javac -cp .;D:\Program Files\apache-tomcat-7.0.35-windows-x86\apache-tomcat-7.0.35\lib\servlet-api.jar Ch1servlet.java
You're 99% of the way there, you just need to put some extra quotes in because the path to your servlet API jar contains spaces. 您已经完成了99%的工作,只需添加一些引号,因为Servlet API jar的路径包含空格。 Try this:
尝试这个:
javac -cp ".;D:\Program Files\apache-tomcat-7.0.35-windows-x86\apache-tomcat-7.0.35\lib\servlet-api.jar" Ch1servlet.java
It will not be because 不会因为
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.