Restart myself - can I reinitialize everything from scratch?

后端 未结 6 1438
無奈伤痛
無奈伤痛 2021-01-27 01:27

I have something like this:

public static final String path;
static {
    path = loadProperties(\"config.conf\").getProperty(\"path\");
}

public static void mai         


        
6条回答
  •  北恋
    北恋 (楼主)
    2021-01-27 02:32

    If you have an UI or a daemon so you can control output to stdout, you can make a wrapper on the outside that starts your program.

    If the program upon exit outputs "RESTART" you can restart your program again from this wrapper. If not, it just ends.

    Or if you want the pure java way, you can go with a solution with classloaders as Peter Lawrey mentioned in his post. Before going down this route you should really rethink your design (if it is your code) and make your code capable of cleaning itself up.

提交回复
热议问题