1

我正在使用 launch4j maven 插件为我的应用程序生成一个 .exe。这就是我在 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 cmd 来完成,那么也许您可以通过这种方式将其直接添加到 java 调用中

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