Swapping a running jar at runtime

I am building an update system in which I need to be able to replace a referenced jar of a running application jar at runtime. However, I am running into file locking issues on Windows when trying to perform file utility functions on the jar such as 'setLastModified'.

After some googling I found this snippet...

What I found in my research is that the standard ClassLoader implementation never closes a jar file once it has been opened. It also only loads resources from the jar file as needed. So at any particular time, there may be Classes in the jar file that have not been loaded into memory. Obviously, if you delete the jar file out from under the ClassLoader, and it tries to find a resource in the missing file, you're going to get an IOException at the very least.

Does anyone have any references to information on doing this, or working around this issue?

Thanks.

5
задан cweston 3 April 2017 в 15:14
поделиться