簡體   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