I have a server program running a java binary code (xx.jar file). While it is running I erroneously delete the xx.jar file. The program continues to run. But I am not sure if the results will be correct, and I am not sure if the program will fail.
When I delete the xx.jar file, the program was in a method for a long time and still it is in that method call. When it calls another method call will, my program fail?
I am asking this question because If deleting the file has no harm I will be gaining about 3-4h on a server machine
You cannot delete a JAR file while any components that reference the file are deployed.
To learn more, see Using the Change Center. From the left navigation pane, select JARs from under Resource Browser. The Summary of JARs page is displayed. In the Options field of the JAR you want to delete, click the Delete icon.
A Java Archive, or JAR file, contains all of the various components that make up a self-contained, executable Java application, deployable Java applet or, most commonly, a Java library to which any Java Runtime Environment can link.
There is no guarantee that the JVM will load all classes from a .jar
file into memory, although it may pre-load some or all of the .jar
as an optimization.
If this fails, and I imagine it would at some point, it would not happen during the middle of execution of a method. It would be at a point where a new class must be loaded from the classpath and the JVM can't access that file anymore. Then you would fail with NoClassDefFoundError
or worse.
So, no, I would definitely not advise you to do this, even if it happens to work in some cases.
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