Wednesday, 11 September 2013

Updating a .jar file that is in use

Updating a .jar file that is in use

I have a C# program that updates and then launches a Java application.
Before actually launching Java, it checks for updates to the .jar files
that program uses. It's possible that multiple people are running the
application on a given machine at one time (it could be a terminal server)
or that the same user is running multiple instances of the program. If
other people are running the application, the .jar file will be in use and
can't be updated. I'm trying to work around this.
My preference would be to rename the .jar file and update it. All the
people currently running the application can still use the renamed jar
file. Windows won't let you rename a file that's in use, either (though I
think Unix systems will).
I noticed that with Windows Explorer, though, you can copy/paste a jar
file and overwrite a .jar file that's in use. How does that work, and can
I somehow do something similar in my updater/launcher program?
Are there any other approaches I might use?

No comments:

Post a Comment