This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting the name of a jar file from inside the jar

 
Jason Kretzer
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • 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
  • 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,
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ivor Horton
Author
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
No, I need the name of the jar to instantiate the JarFile object to begin with.
Thanks though,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic