• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is it possible to update an entry in an executing Jar file?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm writing an executable Jar file which contains one class (to FTP data to another machine) and one properties file (which contains amonsgst other things a unique sequence number to go in each new filename).
Each time the Jar executes, the last thing it must do is increment the sequence number by one. Unfortunately I can't do this while it's in the Jar file. I know of a method whereby you create a temp jar file, add your new entry then copy the remaining files. Finally you would delete the original and then rename the temp.
Which would be great if I didn't have a lock on the jar file because it's being used to run the program in the first place.
D'oh!
So, to cut a long story short - Is it possible to update one file (ie overwrite an existing entry) in an executing jar without having to rewrite the entire thing?
Many thanks
[ June 19, 2002: Message edited by: James Mills ]
 
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. But it would be possible to have a separate parent process in charge of renaming the jar. Instead of running program.jar (or whatever it's called) as you usually might, call launcher.jar which will in turn call program.jar and do the renaming when everything is done.
 
Simon Machin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like a good idea, I'll give it a go.
Cheers
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic