This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm currently reading HF Servlets & JSP and am having trouble compiling one of their examples at the end of chapter 3. I get an error when I try and compile the program called "BeerSelect" (that is stored in the com.example.web package). The error states that the previously compiled package (called com.example.model) does not exist. I'm following the book so far, but I'm not able to get this last code to compile....
Any ideas or suggestions? I'm sure it has something to do with my classpaths or other environmental settings, but I'm not all that familiar with how they work in concert with the compiler.
When you compile BeerSelect, try adding the classpath to the javac command so that it knows where to find the imported package. For example, if your directory structure is c:\myjava\com\example\model, and your import statement is import com.example.model; then use...
javac -classpath c:\myjava\ BeerSelect.java
(See this section from Thinking in Java for more detail.) [ February 16, 2006: Message edited by: marc weber ]
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
This might sound stupid, but do you have your package in a proper subdirectory? For your package, it would have to be "/com/example/model/" and all the example files from the book in that package would have to be there. If not, you'll have to include the classpath to their location as well. (They still have to be in the proper directory, of course.) [ February 16, 2006: Message edited by: Jeremy Tartaglia ]
Joined: Feb 16, 2006
Thanks to both of you for responding. Adding a CLASSPATH environment variable did the trick. This leads me to my next question:
From a configuration management perspective, on large development projects where there are teams of developers, does each developer add their own path to the CLASSPATH on the development machine?
Thanks again. I cna now continue on to the next chapter!