• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with importing my own packages

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Any suggestions would be greatly appreciated.

Scott
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

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 ]
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Scott Updike
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!

Scott
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If all the developers work in their private directory, then I think, they all have to set their own classpath in the environment variables.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic