Recompiling and rerunning Java code while it is running

On a Unix environment, if I am running Java code and I would like to re-run it with different parameters, can I recompile it without losing data? Will the previous Java task work without getting stuck?

Cheers, Simone

+3


source to share


1 answer


You can run multilpe instances of the same java program with different (command line) parameters without recompiling.



It is possible to run different versions of the same program and recompile at runtime, but if you modify the class file while the program is running, it can affect the current runtime if the file has not been loaded yet. You must create another working copy of the class files or jar files and then run the copy after modifying it if you want to run two different versions at the same time. If your program changes can be changed to properties file or other motives of config files, I think this is the best solution.

+3


source







All Articles