How to replace classes in a running application in java ?

后端 未结 6 2032
有刺的猬
有刺的猬 2020-12-04 18:36

Say I have a class named NameGenerator. I can use this to generate names according to a given logic. Then I write a TestNameGeneration class with a

6条回答
  •  旧时难觅i
    2020-12-04 18:44

    You can write your own custom classloader. When ever there is change in the class file or resource/jar containing the class file (check the timestamp), destroy the previous classloader instance and create a new classloader instance which in turn will load the new class file.

提交回复
热议问题