I have a problem to compile the source code for a class that is in the book "head first servlets ...", and this problem is generated by the instruction: import com.example.model.*; from the code. How it was said in the book I had a folder tree like (beerV1\classes\com\example\model\) in which is the class that I want to import (BeerExpert.class). The BeerSelect.java file is in beerV1\src\com\example\web\ and I try to compile it, from beerV1 folder how it was write in the book. But I receive the following error: package com.example.model does not exist. I think this may happend because the compiler look in the root folder (beerV1) to find the com folder, but it is in the classes folder. If I try to compile the file being in the classes folder and using the comand:
javac -d D:\Java\Java programs\Head first Servlets and JSP\beerV1\src\com\example\web\BeerSelect.java I recieved the error: invalid flag: programs\Head
Can someone help me in this matter? Thank you!
You have spaces in your path. D:\Java\Java programs\Head first Servlets and JSP\beerV1\src\com\example\web\BeerSelect.java. Either rename the folders to NOT have the spaces in the name or enclose the path in double quotes "......."
Joined: Feb 16, 2011
I solved finaly the problem by using the comand set CLASSPATH=C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\servlet-api.jar;classes;.;
and after I compile the code using the comand: javac -d classes src\com\example\web\BeerSelect.java
I don't know why the environment variables didn't work (I put in the variable value the same path, but didn't solve the compile problem), but I'm happy it finaly work!