简体   繁体   English

Marathon JAVA 驱动程序 - 在从 Eclipse 导出的 JAR 文件中运行时出错

[英]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.以下步骤为我解决了这个问题。

  1. Download selenium-standalone-jar and add it to the project build path下载 selenium-standalone-jar 并将其添加到项目构建路径中
  2. As suggested by Aditya, export the project as runnable JAR file with option "copy required libraries into a sub-folder next to the generated JAR"按照 Aditya 的建议,将项目导出为可运行的 JAR 文件,并带有选项“将所需的库复制到生成的 JAR 旁边的子文件夹中”
  3. In the exported JAR, make sure the manifest file includes the selenium-standalone-jar and other dependencies in the classpath在导出的 JAR 中,确保清单文件在类路径中包含 selenium-standalone-jar 和其他依赖项

This resolved the issue for me.这为我解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从Eclipse运行导出的JAR时出现NoClassDefFoundError - NoClassDefFoundError when running exported JAR from Eclipse 带导出的可运行jar文件的Java Eclipse错误 - Java eclipse error with exported runnable jar file 从eclipse导出我的Java游戏,运行时出错 - Exported my Java game from eclipse, and it gets an error when running 运行Eclipse导出的jar时“找不到主类”错误 - “Could not find the main class” error when running jar exported by Eclipse 在导出的 JAR 中加载图像,但从 eclipse 运行时不加载 - Images loading in exported JAR, but not when running from eclipse Java Eclipse - 导出到.jar时找不到.txt文件 - Java Eclipse--.txt File Not Found When Exported To .jar Java项目在Eclipse上工作但在导出到runnable jar文件时不起作用 - Java project working on Eclipse but not working when exported to runnable jar file 在运行可执行jar文件时找不到类错误(带有Eclipse的导出RMI应用程序) - Not found class error in running executable jar file (exported RMI application with eclipse) 从Java程序在其他jar中运行jar文件 - running jar file inside other jar from java program 在运行时编译Java文件可在Eclipse上运行,但不能从导出的可运行jar文件中运行 - Compiling java file at runtime works on eclipse but doesn't work from an exported runnable jar file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM