我愿意在应用程序中添加一个按钮,单击该按钮将重新启动该应用程序。我搜索谷歌,但没有发现任何有用的,除了这一个。但是,此处遵循的过程违反了Java的WORA概念。
是否有其他以Java为中心的方法来实现此功能?是否可以只派生另一个副本然后退出?
提前致谢。我感谢您的帮助。
@deporter我已经尝试过您的解决方案,但是它不起作用:(
@mKorbel我写的,采取的概念下面的代码,你曾在所示这样
JMenuItem jMenuItem = new JMenuItem("JYM");
jMenuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(10);
executor.setContinueExistingPeriodicTasksAfterShutdownPolicy(true);
executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(true);
ScheduledFuture> future = executor.schedule(new Runnable() {
@Override
public void run() {
try {
Process p = Runtime