1

アプリケーション用に .exe を生成する launch4j maven プラグインを使用しています。これは私がpom.xmlに持っているものです:

        <plugin>
            <groupId>com.akathist.maven.plugins.launch4j</groupId>
            <artifactId>launch4j-maven-plugin</artifactId>
            <version>1.5.1</version>
            <executions>
                <execution>
                    <id>step-1-build-exe</id>
                    <phase>package</phase>
                    <goals>
                        <goal>launch4j</goal>
                    </goals>
                    <configuration>
                        <dontWrapJar>true</dontWrapJar>
                        <headerType>gui</headerType>
                        <outfile>target/MyApplication.exe</outfile>
                        <jar>${project.artifactId}-${project.version}.jar</jar>
                        <errTitle/>
                        <cmdLine>-Xms25m -Xmx50m</cmdLine>
                        <chdir>.</chdir>
                        <priority>normal</priority>
                        <downloadUrl>http://java.com/download</downloadUrl>
                        <supportUrl/>
                        <customProcName>false</customProcName>
                        <stayAlive>false</stayAlive>
                        <manifest/>
                        <icon>${project.basedir}/src/main/assembly/MyApp.ico</icon>
                        <classPath>
                            <mainClass>com.company.app.MainApp</mainClass>
                            <addDependencies>false</addDependencies>
                            <preCp>config;koala.jar;comm.jar;jniwrap.jar;log4j-1.2.12.jar</preCp>
                        </classPath>
                        <jre>
                            <path>jre</path>
                            <minVersion/>
                            <maxVersion/>
                            <jdkPreference>preferJre</jdkPreference>
                        </jre>
                    </configuration>
                </execution>
            </executions>
     </plugin>

私が望んでいたのは、「config」ディレクトリがクラスパスの最初になることですが、メインクラスを含むjarは常にクラスパスの最初に置かれます。最初に構成ディレクトリを配置したいので、メインのjarにもある特定の構成ファイルを簡単に上書きできます。

クラスパスをhttp://www.mkyong.com/java/how-to-print-out-the-current-project-classpath/で印刷して、それが何であるかを確認しました。

4

1 に答える 1

0

プレーンな Java コマンドを使用して実行できる場合は、この方法で Java 呼び出しに直接追加できます。

<jre>
    <path>jre</path>
    <minVersion/>
    <maxVersion/>
    <jdkPreference>preferJre</jdkPreference>
    <opts>
        <opt>-cp yourclasspath/opt>
    </opts>
</jre>
于 2013-12-13T11:15:50.950 に答える