Hi, I am new to servlets. I was going through the book Head First Servlets and JSP and in chapter 3 ...Servlet version 2 ....when I am trying to compile the BeerSelect.java it is giving error that package com.example.model does not exist.
If anyone can explain me the possible reasons for this.
I have already created the BeerSelect.java as foolows:
and the BeerExpert.java file as:
I am using tomcat7 and i m not using eclipse or any other IDE.
Right the issue is with the invocation of the compiler on the command-line. Lets start with the structure on the file system - what does that look like? Where are the .java files are located and where is the .jar file located that provides the Servlet API dependencies? We can work out how to invoke the javac compiler from there.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
@Bear Bibeault : Thanks .....I will take care of that from next time.
@Jelle Klap & Saket Kumar Sinha:
The location for BeerExpert.java file is E:\MyProjects\beerV1\src\com\example\model\
for BeerSelect.java file is E:\MyProjects\beerV1\src\com\example\web\
for servlet-api.jar is E:\tomcat7\lib
and the command I am using for compilation is javac -classpath /E:/tomcat7/lib/servlet-api.jar;classes:. -d classes src/com/example/web/BeerSelect.java.
and I am getting 3 errors: one at line3 and two at line 14.
it is saying that package com.exampe.model doesnot exist.
The BeerSelect.java file is compiling if we replace the colon(":") after classes with semi-colon(;)
javac -classpath /E:/tomcat7/lib/servlet-api.jar;classes;. -d classes src/com/example/web/BeerSelect.java
But I have a doubt.When I was compiling the servlet version 1 as given in the book,it was compiling fine with the colon(":"). So why is the servlet version 2 not compiling?
the difference between colon and semi-colon(;) is that the former is used in unix/linux systems. so i you have to specify classpath or other environement variable on those systems you have to use colons for e.g.
/home/admin:/var/lib/myfiles:. // for linux systems
however on our windows machines the corresponding character for colon is semi-colon(;). so classpath on windows machines looks like for e.g
c:/program files/java/jdk/bin;d:/myprojects // on windows machines.