【发布时间】: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