Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Paul Clapham
Sheriff
Posts: 20713
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20492
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Servlets.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By placing it on the class path or by packaging it as a jar and placing it in lib
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64608
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic