1. Compile the model this way from src folder: javac -d ../classes com/example/model/BeerExpert.java This will create a folder called classes in the parent directory of src (..) and put com.example.model.BeerSelect class file in that package structure in the created classes directory.
2. Compile the servlet this way from src folder: javac -classpath /Tomcat_5.5/common/lib/servlet-api.jar -classpath ../classes -d ../classes com/example/web/BeerSelect.java
3. Copy the contents of the classes folder to <your_application_in_server>/WEB-INF/classes folder.
4. When you register this servlet in web.xml, do not forget the full qualified class name (including the package structure)
If the first step does not create a folder named classes, manually create one in the parent directory of src folder before trying these steps.
Joined: Mar 26, 2005
i did as you said from step 1 and 2. but step 3 when i compile using exactly what you said, it gave me error like "package javax.servlet does not exist" and the rest of javax.servlet and javax.servlet.http also no exist.
gosh, once this problem not fix, i hardly to continue to chapter 5 of HFSJ.
Joined: Sep 11, 2005
Step 3 is only a copy-paste operation to migrate from development to deployment. There is no compilation involved there.
1. Were your packages (com.example.model and com.example.web) recognized when you tried to compile in steps 1 and 2?
2. Try setting the system CLASSPATH to point to servlet-api.jar instead of passing it as an option with javac.
Joined: Mar 26, 2005
i know where is the problem already...gosh, i used 2 hours just now to find the wrong path....
my all path of each file and classes did not wrong. i was wrong at this:
I have the same problem as Nicky, I have the system CLASSPATH set to point servlet-api.jar so when I compile I just put javac -d src/com/example/web/BeerSelect.java
How can I introduce the word ;classes; in the statement so I don't have to put the whole path everytime? I'm trying different statements but I still get 'package com.example.model does not exist'
I also tried: javac -classpath servlet-api.jar;classes; -d classes src/com/example/web/BeerSelect.java but then it doesn't find the javax packages too.
Thanks for the help
Joined: Jul 11, 2009
In my CLASSPATH I got the following: