wood burning stoves*
The moose likes Servlets and the fly likes how to let Java class in jar files in lib folder to access class in the web application? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to let Java class in jar files in lib folder to access class in the web application?" Watch "how to let Java class in jar files in lib folder to access class in the web application?" New topic
Author

how to let Java class in jar files in lib folder to access class in the web application?

reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
Normally I create helper classes and build a jar file, then put jar file in the lib directory of the web app. But if I want the helper class in the lib directory to access class in the web application src directory, what should I change?

Thanks.


SCJA, SCJP5.0, SCBCD, SCWCD
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

What's that "src" directory? The standard place to put classes in a web application, if they aren't in a jar, is in the WEB-INF/classes directory. Classes in jar files in the WEB-INF/lib directory can access those classes because both locations are in the classpath of the web application.
reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
You are right. WEB-INF/classes is the place for compiled classes. When I write java classes, it's in src.
Anyway, my question is about how to let a java class in the jar in the lib directory to access a java class not in the lib directory.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

Moving to Servlets.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

By placing it on the class path or by packaging it as a jar and placing it in lib


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

You don't have to do anything.

If you place the class files in one of the correct locations, they all get loaded into on big happy JVM where they can all play nicely together.

The sources play no part in the deployed web application.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to let Java class in jar files in lib folder to access class in the web application?
 
Similar Threads
JSP Helper classes in Tomcat
using hibernate in J2EE app
Not able to access BouncyCastle jar from Application jar
jsp upload
regarding jar file in web application