• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Running jar from anywhere

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks,

I've recently put an executable jar file together which is dependant on several other jar files. When I create the executable jar file I ammend the classpath in the manifest to include those libraries,

i.e. Class-Path: ./lib/jasperreports-1.2.3.jar ./lib/log4j-1.2.13.jar

these references are obviously relative to the location of the executable jar file. If I then run the executable jar file from its own directory everything works fine. However, if I run it from another directory the classpath obviously points to the wrong location, and nothing works.

How do I set the classpath so that it's relative to the executable jar file no matter where I run it from?

The reason I want to know is that I'm planning to execute the jar from a cgi file, however the cgi file could be located anywhere.

Thanks
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The easiest thing to do would be to unjar all the third party jars, combine with your class files and make one large jar.
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the easiest thing to do is add them to the MANIFEST.MF file. Jars listed in MANIFEST.MF are relative to the location of the jar containing it.


[ October 16, 2006: Message edited by: Tim LeMaster ]
reply
    Bookmark Topic Watch Topic
  • New Topic