繁体   English   中英

如何执行 Quickfix/J jar?

[英]how to execute Quickfix/J jar?

我正在使用 quickfix/j 库构建一个独立的交易模拟器。 到目前为止,我一直在使用 mvn package,然后是 intelli J“运行按钮”从我的客户端应用程序 class 中的入口点运行我的程序。 我尝试使用java -jar target/.....1.1.0.jar 并得到以下错误

java -jar Broker/target/Broker-1.0.0.jar
Error: Could not find or load main class Broker.ClientApplication
Caused by: java.lang.NoClassDefFoundError: quickfix/Application

我认为该错误可能与我的 pom 文件没有正确获取依赖项有关。 因此,为了确保我从 quickfix/J github 运行了ordermatch示例,但我得到了类似的错误。

java -jar /homes/antonga/IdeaProjects/Desktop/quickfixj-parent/quickfixj-examples/ordermatch/target/quickfixj-examples-ordermatch-2.1.1-sources.jar

no main manifest attribute, in /homes/antonga/IdeaProjects/Desktop/quickfixj-parent/quickfixj-examples/ordermatch/target/quickfixj-examples-ordermatch-2.1.1-sources.jar

为了清楚起见,使用主类中的 Intellli J“运行”按钮即使对于 ordermacth 示例也可以完美地工作。 从我收集到的 IntelliJ 使用的命令"/path/to/java/" "-javagent/.../.jar" "/pathtolocalmavenrepo/quickfix-core.jar "/pathtolocalmavenrepo/anotherquickfixdependecy.jar"....."more quickfix dependency jar files" packagestructure.Main

我不明白为什么这会起作用,但我的执行不会。 如果这有帮助,我可以包含我的 pom 文件和其他信息。 我也在使用多模块 maven 项目,但这似乎不是问题。

原来我是个菜鸟。 Maven package 生命周期将没有依赖关系的指定 class 文件捆绑到 Z68995FCBF432492DAC45048DZ49中。 我需要用所有必要的二进制文件创建一个超级 jar,然后运行它。 请参阅 SO question create excecutable jar with dependencies using maven

需要的是以下内容:

java -classpath <list-of-all-jars> <main-class>

<list-of-all-jars>是一个; (Windows) or: (*nix) separated list of all jars needed to run your program (quickfixj jars, your own jar and any jars needed), and <main-class> is the fully qualified class name of your main class (the class 具有您的应用程序的主要入口)

您必须创建一个可执行文件 jar。 您可以使用 Maven 来执行此操作。 在你的 pom.xml 可以使用 maven-assembly-plugin 来生成你的可执行文件 jar

<plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>myour.main.Class</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM