Java (TM) 平台 SE 二进制文件仍在 运行 进程中

Java (TM) Platform SE binary still running on processes

我使用 Java 创建了一个控制台应用程序,然后将其导出为 运行 可用的 JAR 文件。但是当我 运行 JAR 文件自动化完成但 "Java (TM) Platform SE binary" 仍在后台时,我尝试放入 System.exit(0) 但仍然无法终止进程。

我也在尝试 运行 在 Task Scheduler 中每 15 分钟自动无限重复一次,问题是它不会 运行 在 之后的 15 分钟后再次"Java (TM) Platform SE binary" 仍在处理中,并将其状态确定为 运行ning。

我很确定我的所有自动化任务都已无误地完成并且没有创建另一个线程。

下面是我的代码:

public static void main(String[] args) {
    String jarName = new File(Selenium.class.getProtectionDomain().getCodeSource().getLocation().getPath())
        .getName();
    System.out.println("Running " + jarName + " Automation");
    if (args.length >= 1 && args[0].toLowerCase().equals("-run")) {
        for (int i = 1; i < args.length; i++) {
            String pram = args[i].replace(jarName + "_", "");
            if (pram.toLowerCase().equals("all")) {
                GFC.execute("Login");
                GFC.execute("SwitchIntegration");
                GFC.execute("BODActivate");
                GFC.execute("Users");
                GFC.execute("Settings");
                GFC.execute("AccountingEntityRegistration");
                GFC.execute("CustomizedData");
                GFC.execute("BOD");
                GFC.execute("BODAttributesMDM");
                GFC.execute("BODAttributesTransactional");
                GFC.execute("CMD");
                GFC.execute("CMDAttributes");
                GFC.execute("CMDDataEntry");
                GFC.execute("CMDActivate");
                GFC.execute("AccountingEntity");
                GFC.execute("AccountingEntityMapping");
                GFC.execute("JETemplates");
                GFC.execute("Scenarios");
                GFC.execute("Rules");
                GFC.execute("RulesScript").quit();
            } else {
                if (!pram.equals("Login")) {
                    GFC.execute("Login");
                }
                GFC.execute(pram).quit();
            }
        }

        if (Boolean.parseBoolean(infor.automation.utils.Properties.get("gfc.enableemailer"))) {
            sendEmail();
        }
    }
}

更新:2018/3/14

我制定了解决方法或可能是解决方案。我发现 main 上的 System.exit(0) 只会关闭控制台应用程序,但 "Java (TM) Platform SE binary" 将保留。为了终止这个,我扩展到 JFrame class 以便能够覆盖 ExitApp()。在 ExitApp() 中,我添加了 window 侦听器,在 windowClosing() 中,我再次调用了 disposed()System.exit(0)。我不知道这是怎么回事。如果有人知道这是如何工作的,请随时更新此答案。

public class TestClass extends JFrame {

    public void ExitApp() {
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                // Dispose Java (TM) Platform SE binary.
                dispose();
                // Close the Java.exe I'm not sure.
                System.exit(0);
            }
        });
    }

    public static void main(String[] args) {
        // Close Your Application Trigger ExitApp();
        System.exit(0);
    }
}