Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

wars and classpath ?  RSS feed

 
Yves Carlson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

Not sure where to post this, sorry if it's in wrong section...

I'm sorry for posting such simple question, but I was really unable to google anything usefull.

So, I will keep things as simple as possible.
I have a small jar file whose only purpose is to print something (e.x."Hello world"). So, jar is only
one class / one function.

Now, my goal is to import this jar into simple jsp and use it to print this simple text, so I could confirm that external jar is used.

And, here is where trouble starts for me. I would like pack this mini web app into war,
which, once in container's webapps folder will automatically add this external jar to the classpath.

Based on my tries, I take it that manifest file's Class-Path for some reason doesn't work for war files ?

I would really appreciate if someone could explain me how to accomplish this ?

Thank you for any help!

 
Ramanan Pathmaraj
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try 1. WEB-INF 2. WEB-INF/lib 3. WEB-INF/classes ?
 
Yves Carlson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, i belive that my folder structure is correct, mainly because if I add manually jar to the classpath everything works ok, I'm just trying how can jar automatically be added to the classpath ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Based on my tries, I take it that manifest file's Class-Path for some reason doesn't work for war files ?

Manifests are not needed for web applications. The Servlet specification defines what is on the web application's classpath, namely WEB-INF/classes and WEB-INF/lib.

What do you mean by automatically adding stuff to the classpath?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Paul pointed out, if the jar file is in the war's WEB-INF/lib, and the war is properly formed and properly deployed in a container, the jar files in WEB-INF/lib will be part of the classpath. No other goop is necessary.
 
Yves Carlson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you were right, WEB-INF/lib did it for me, I wasn't sure what I did wrong,my bad, but if jars are in WEB-INF/lib they're automatically available to the app. Thanks for help everyone.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!