OK, this topic may get moved over to the
JSP or the
Servlets forums because of this post, but in my original post I was just trying to understand
java package and import statements in general. Anyway�
Here is the exact syntax of my code and the javac commands. I�m trying to work an example out of Head First Servlets and JSP (chapter 3, pp80-85).
Package statement syntax: package com.example.model;
This package statement is inside a file named BeerExpert.java
Import statement syntax: import com.example.model.*;
This import statement is inside two different files BeerSelect.java and ModelTest.java.
My directory structure looks like this: BeerExpert.java: C:code/java/myProjects/beerV1/src/com/example/model
BeerSelect.java: C:code/java/myProjects/beerV1/src/com/example/web
ModelTest.java: C:code/java/myProjects/beerV1/src/com/example/model
I�ve created batch files for compiling my .java files, here are the commands: BeerExpert.java: javac -classpath ../../../../../../../"Program Files"/"Apache Software Foundation"/"Tomcat 5.0"/common/lib/servlet-api.jar -d classes src/com/example/model/BeerExpert.java
BeerSelect.java: javac -classpath ../../../../"Program Files"/"Apache Software Foundation"/"Tomcat 5.0"/common/lib/servlet-api.jar -d classes src/com/example/web/BeerSelect.java
ModelTest.java: javac -classpath ../../../../../../../"Program Files"/"Apache Software Foundation"/"Tomcat 5.0"/common/lib/servlet-api.jar -d classes src/com/example/model/ModelTest.java
I compile BeerExpert first and it compiles (this should create the package). It also creates the directory structure com/example/model where it places the BeerExpert.class file. When I try to compile BeerSelect.java or ModelTest.java they both come up with the �package does not exist� error.