【问题标题】:Java (TM) Platform SE binary still running on processesJava (TM) Platform SE 二进制文件仍在进程上运行
【发布时间】:2018-03-14 03:40:42
【问题描述】:

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

我也试图在任务计划程序中自动运行它,每 15 分钟无限重复一次,问题是它不会在 “Java (TM) Platform SE 二进制文件”后 15 分钟后再次运行 仍在进行中,并确定其状态为正在运行。

我很确定我所有的自动化任务都已完成,没有错误,也没有创建另一个线程。

下面是我的代码:

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 日

  • 担心我的自动化可能会创建另一个线程,所以我决定 创建一个新项目和一个主类并将其导出为 可运行的Jar文件,还是一样。
  • 我的JDK版本是1.8

【问题讨论】:

  • 你的结束后jvm中会不会有另一个线程在运行?您是否正确关闭了 selenium?
  • @HSchmale 你是说 WebDriver 吗?如果是这样,我已经验证过了,但是进程中没有 chromedriver.exe 或任何相关驱动程序。
  • @LeonelSarmiento 我假设另一个线程也在 jvm 中运行。尝试使用 JStack 找出 JVM 中正在运行的线程。

标签: java selenium taskscheduler


【解决方案1】:

我做了一个变通办法,或者也许是一个解决方案。我发现 main 上的 System.exit(0) 只会关闭控制台应用程序,但 “Java (TM) Platform SE binary” 将保留。为了终止这一点,我扩展了JFrame 类,以便能够覆盖ExitApp()。在ExitApp() 中,我添加了窗口侦听器,在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);
    }
} 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-17
    • 1970-01-01
    • 2012-01-08
    • 1970-01-01
    相关资源
    最近更新 更多