I have created an application, in which based on an operation, it modifies the properties file inside the jar.
I'm able to create a new temp jar with the updated changes. But can't rename the jar file to the existing jar file name. Since it is running, I am not able to delete and rename it.
Can any one suggest any operations or suggestions to delete the jar (Currently Executing) and rename the temp jar to that name?
I have doing for the Application: http://java.net/projects_tags/jeazyprops
You're problem is the default ClassLoader that pre-java 1.7 uses - it locks any jar that it loads and doesn't release the jar until execution completes. The easiest solution is to use Java 1.7 which should solve this problem. Otherwise you can write your own custom ClassLoader (ugh). Default ClassLoader: http://docs.oracle.com/javase/6/docs/api/java/net/URLClassLoader.html
EDIT
And here's the note from Oracle saying they fixed it in Java 1.7: http://openjdk.java.net/projects/jdk7/features/#f584
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With