aspose file tools
The moose likes Java in General and the fly likes Pinning down the location of a jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Pinning down the location of a jar file" Watch "Pinning down the location of a jar file" New topic
Author

Pinning down the location of a jar file

Greg Jewell
Greenhorn

Joined: Mar 08, 2002
Posts: 10
Hi All,

I have a class inside a jar that wants to read the containing jar's manifest. Given that I don't know where on the machine the jar will be placed, I don't know how to instantiate a JarFile object. How do I determine the location of the jar in order to get a JarFile or JarURLConnection object?


Thanks,
Greg Jewell
Petr Blahos
Ranch Hand

Joined: Apr 28, 2004
Posts: 131


The output of this is:

jar:file:/D:/cygwin/home/petr/java/jar/jjj.jar!/my/package/jar


I hope it will help.

Petr


Get a better web browser:<br /><a href="http://www.mozilla.org/products/firefox/switch.html" target="_blank" rel="nofollow">http://www.mozilla.org/products/firefox/switch.html</a>
Petr Blahos
Ranch Hand

Joined: Apr 28, 2004
Posts: 131
Oh, BTW there is a _VERY_ nice article starting with class loader
explanation, going on through reflection to runtime code generation:

http://www-106.ibm.com/developerworks/java/library/j-dyn0429/

Enjoy!
P.
Greg Jewell
Greenhorn

Joined: Mar 08, 2002
Posts: 10
Thank you very much, Petr. This is exactly what I was looking for.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pinning down the location of a jar file
 
Similar Threads
getting the name of a jar file from inside the jar
including a file in a build
Linux Installer for a Swing Application
load a jar file
creating jar file programatically