Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

getting the name of a jar file from inside the jar

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a jar. This jar has code in it similar to this:

studyJar is a JarFile representation of the jar this code is executing in. I get studyID and studyVersion from a text file located inside the jar.
I need to add the functionality where the jar can be renamed by end users.
Is it possible for code inside of a jar to get the name of the jar it resides in? I need its name to instantiate the JarFile above.
Thanks,
[ March 28, 2002: Message edited by: Jason Kretzer ]
 
Jason Kretzer
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you do not believe it to be possible at least tell me that. I don't want to waste my time looking for something that is not there.
Thanks,
 
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is one solution. It's painful. I hope there is a better way, but I don't know one.
Grrr. HTML is not enabled.

[ March 28, 2002: Message edited by: David Weitzman ]
 
Author
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jason,
I haven't tried it but if you have the JarFile object, the getName() method that is inherited from java.util.ZipFile might help.
 
Jason Kretzer
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I need the name of the jar to instantiate the JarFile object to begin with.
Thanks though,
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic