File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Locating a jar file relative to the application

 
Hanna Habashy
Ranch Hand
Posts: 532
  • 0
  • Mark post as helpful
  • send pies
  • 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,
 
Saurabh Deshpande
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about using the JarURLConnection class?

JarURLConnection Javadoc



I hope that helps!
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic