• 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

Locating a jar file relative to the application

 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all:

I have a class C that is in a jar file. The class looks for resources in 3 other jar fils. All the jar files are located in the lib directory of an application.

How can I make class C find those jar files? I need to get the URL of the required jars.

I tried
URL url = class.getResource("A.jar");
URL url = class.getResource("\\A.jar");
URL url = class.getResource("..\\A.jar");

but nothing is working. Any ideas?

Thanks,
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i dont think you need to do anything in the code.
you simply need to add the jars to the CLASSPATH
and it will be taken care of.

let me know if the problem still persits after adding the jars to CLASSPATH
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about using the JarURLConnection class?

JarURLConnection Javadoc



I hope that helps!
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Hanna Habashy:]the jar files are located in the lib directory of an application.

What application ?

http://www.javaworld.com/javaworld/javaqa/2003-08/01-qa-0808-property.html
[ September 18, 2007: Message edited by: Nicholas Jordan ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic