[英]Marathon JAVA Driver - Error when running inside an exported JAR file from Eclipse
I have got Marathon JAVA Driver to work in Eclipse and it works fine when I run the code from eclipse.我有 Marathon JAVA 驱动程序在 Eclipse 中工作,当我从 eclipse 运行代码时它工作正常。 However, When I export the project as runnable JAR file, and then execute the JAR file, I get the below error and the application is not launched.但是,当我将项目导出为可运行的 JAR 文件,然后执行 JAR 文件时,出现以下错误并且应用程序未启动。
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61) Caused by: java.lang.NullPointerException at net.sourceforge.marathon.javadriver.JavaProfile.(JavaProfile.java:205) at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61) Caused by: java.lang.NullPointerException at net.sourceforge.marathon.javadriver.JavaProfile.(JavaProfile.java:205)
import java.io.IOException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import net.sourceforge.marathon.javadriver.JavaDriver;
import net.sourceforge.marathon.javadriver.JavaProfile;
import net.sourceforge.marathon.javadriver.JavaProfile.LaunchMode;
import net.sourceforge.marathon.javadriver.JavaProfile.LaunchType;
public class SwingAutomationSample {
public static JavaDriver driver;
public static JavaProfile profile;
@BeforeClass
public void setUp() throws IOException {
try {
profile = new JavaProfile(LaunchMode.EXECUTABLE_JAR);
profile.setLaunchType(LaunchType.FX_APPLICATION);
profile.setExecutableJar("C:/Users/KarthikRaja/Desktop/Projects/xxyy.jar");
profile.setWorkingDirectory("C:/Users/KarthikRaja/Desktop/Projects");
driver = new JavaDriver(profile);
}catch(Exception e) {
System.out.println("java driver error ------------ " + e.toString());
}
}
@Test
public void Form15CBFill() throws Exception {
System.out.println("Inside Test Class");
}
}```
Marathon Java driver uses its jar files so that it can set JAVA_TOOL_OPTIONS. Marathon Java 驱动程序使用其 jar 文件,以便它可以设置 JAVA_TOOL_OPTIONS。 So it needs the jar file to be assessable in the file system.因此,它需要 jar 文件才能在文件系统中进行评估。
Please check the JavaProfile.java line number 204 for reference.请检查JavaProfile.java行号 204 以供参考。
For a quick fix export marathon jars and add them to class path and write a batch script to execute the test case.为了快速修复导出马拉松 jars 并将它们添加到 class 路径并编写批处理脚本来执行测试用例。
@Aditya, again, thanks for pointing me in the right direction. @Aditya,再次感谢您为我指明正确的方向。 The below steps solved the issue for me.以下步骤为我解决了这个问题。
This resolved the issue for me.这为我解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.