File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

the class is on the container's classpath

 
A. Aka
Ranch Hand
Posts: 93
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

what does it mean ? the class is on the container's classpath ?
where is the location of container's classpath

can I please have an example of a class which is on the container's classpath and also an example of class which is not ?

regards,


source :HFJS : page 628 (speaking about exception-type in web.xml
"as long as the checked exception class is on the container's classpath"

 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2171
57
Android Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can I please have an example of a class which is on the container's classpath and also an example of class which is not ?

Did you do SCJP? or OCPJ6?

If so, then you better have a look at the last chapter again (Java 6 Study Guide - Katherine Sierra and Bert Bates, Chapter 12 Development)

You will find the answer there.

Regards,
Frits
 
A. Aka
Ranch Hand
Posts: 93
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Frits, I think I understand the concept of classpath in java 6 (-classpath dir1:dir2), however I do not get what it means classpath's container!
how do I know that a class is not in classpath's container? is it when compiling my servlet, it cannot find the specific class ?

if it is the same concept as in java, why not say classpath instead of classpath's container ?
 
K. Tsang
Bartender
Pie
Posts: 3225
12
Android Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using any IDE like Eclipse or Netbeans? Because what "classpath container" for these IDEs is that place where you define any jar files or libraries your project may use.

Yet if you are talking about the application server's classpath container, then I reckon it's those jar that comes with Java EE plus those jars you deploy with your WAR or EAR or JAR.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2171
57
Android Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Frits, I think I understand the concept of classpath in java 6 (-classpath dir1:dir2), however I do not get what it means classpath's container!

Ok, sorry, then I didn't understand your question well.

if it is the same concept as in java, why not say classpath instead of classpath's container ?

Yes, the concept is the same, the classpath of a container consists of a number of classes (packaged in jars, e.g. the Servlet implementation class) that are needed during compilation of your web components (but remember they are also needed at runtime) Apart from that you will have to put your classes in the right directory otherwise the container won't be able to load them (and execute them)

Just have a quick look at the following document: HowToCreateWebApplicationWithoutAnIDE.

A web application consists of a standard prescribed structure (Servlet 3.0 ch 10.5 Directory Structure):

10.5 Directory Structure
A Web application exists as a structured hierarchy of directories. The root of this hierarchy serves as the document root for files that are part of the application
...
A special directory exists within the application hierarchy named "WEB-INF".

The contents of the WEB-INF directory are:
- The /WEB-INF/web.xml deployment descriptor.
- The /WEB-INF/classes/ directory for servlet and utility classes. The classes in this directory must be available to the application class loader.
- The /WEB-INF/lib/*.jar area for Java ARchive files. These files contain servlets beans, static resources and JSPs packaged in a JAR file and other utility classes useful to the Web application. The Web application class loader must be able to load classes from any of these archive files.

...

The Web application class loader must load classes from the WEB-INF/classes directory first, and then from library JARs in the WEB-INF/lib directory.


Does this make things clearer?

Regards,
Frits
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yet if you are talking about the application server's classpath container, then I reckon it's those jar that comes with Java EE plus those jars you deploy with your WAR or EAR or JAR.


Not exactly. Additional JARs can be added to an application server's classpath by placing them in defined locations (for example, in JBoss, the lib folder which sits alongside the deploy folder).

There are particular libraries which due to licensing, will forbid you from including its JARs in your deployed artifact. In these cases, you would have to add it to the server's classpath using the aforementioned location.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic