Relative Content

Tag Archive for javajvmfile-locking

delete a jvm-locked file on jvm exit

I have a file that is under lock by the JVM (it is a jar file that provides classes that are loaded at some point during runtime). When my program exits I want to delete this file. However, simply registering it for deletion with File#deleteOnExit() does not do the trick, the file is not deleted. I am assuming this is because the JVM is still running when deleting the files schedules for deletion and therefore my jar is still under lock. Is there a way to delete files under lock by the JVM on JVM exit? Thanks in advance