Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package does not exist error

 
Tom Gibson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to work through the first servlet example in the the Head First Servlets & JSP book.

I am running Apache Tomcat 5.5.23 Server. The path to tomcat is C:\tomcat

Per the example in the book, I created the following
C:\MyProjects\beerV1\src\com\example\web\BeerSelect.java
C:\MyProjects\beerV1\web\form.html
C:\MyProjects\beerV1\etc\web.xml

When I try to compile my class by using:

javac -classpath C:\tomcat\common\lib\servlet-api.jar:classes. -d classes src\com\example\web\BeerSelect.java

I get an error in my DOS window saying "package javax.servlet does not exist."

I'm not sure what I am doing wrong. Am I right in thinking that the package is not being found because the -classpath in my command is somehow wrong? I can see the jar at C:\tomcat\common\lib\servlet-api.jar but it doesn't seem to found in the above line. Please help. Let me know if I need to provide any other information. Thanks!
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The classpath separator on Windows is ; rather than : and you've missed a separator after classes. Change

-classpath C:\tomcat\common\lib\servlet-api.jar:classes.

to

-classpath C:\tomcat\common\lib\servlet-api.jar;classes;.
 
Tom Gibson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joanne -- it works now
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic