【问题标题】:How to add a directory first on the classpath using launch4j and maven?如何使用launch4j和maven首先在类路径上添加目录?
【发布时间】:2012-07-16 01:38:45
【问题描述】:

我正在使用 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/ 打印了类路径,看看它是什么。

【问题讨论】:

  • 在不更改应用程序的情况下查看类路径的更简单方法是使用 --l4j-debug 参数启动 .exe。这将在工作目录中创建一个launch4j.log 文件。

标签: java maven launch4j


【解决方案1】:

如果你可以使用普通的java cmd,那么也许你可以直接将它添加到java调用中

<jre>
    <path>jre</path>
    <minVersion/>
    <maxVersion/>
    <jdkPreference>preferJre</jdkPreference>
    <opts>
        <opt>-cp yourclasspath/opt>
    </opts>
</jre>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-22
    • 2012-04-13
    • 1970-01-01
    • 2021-12-12
    • 1970-01-01
    相关资源
    最近更新 更多