Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing one's own packages in servlets

 
Abhishek Gautam
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys, Please help me in acessing ones own packages in Servlets...
do we have to set the path for its classes...i am just the starter...
How will we do that...if thats the case?
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Three ways I know of:

1. by command line
2. by environment variable
3. by options file
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Update your classpath by adding the dirctory that your package is in to it. I.e the directory that's right above your package directory.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course setting the classpath is only useful for compiling the servlets and classes. The system classpath is ignored by the container serving the web application when deployed.

To deploy the classes, they must be place in one of the locations defined by the Servlet Specification. For example, WEB-INF/classes for standalone classes, or WEB-INF/lib for jar files. There are also container-defined locations to share classes across web apps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic