• Post Reply Bookmark Topic Watch Topic
  • New Topic

Pinning down the location of a jar file  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The output of this is:

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


I hope it will help.

Petr
 
Petr Blahos
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much, Petr. This is exactly what I was looking for.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!