我剛剛提出了一個關於使用javafxpackager製作JavaFX jar的問題,你可以看到它here。我的問題是我無法在清單中包含類路徑。那麼,當我在等待答案時,我試着改爲maven-antrun-plugin
。它工作的很好,我可以用依賴運行我的應用程序,但是(總是有一個但是)只有在我的最後一個罐子外的依賴關係。因此,它是這樣的:JavaFX jar捆綁依賴關係
FinalJar.jar
lib
|_{all dependencies here}
我的清單文件通過JavaFX-Class-Path
屬性指向的依賴關係。如果我把這些依賴關係放入jar中,就像我想的那樣,它沒有找到我的依賴關係。任何幫助?
編輯:下面是依賴添加到罐子,其pom.xml的內部步驟:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<target>
<taskdef name="jfxjar" classname="com.sun.javafx.tools.ant.FXJar"
classpathref="maven.plugin.classpath" />
<jfxjar
destfile="${project.build.directory}/dist/${project.build.finalName}">
<fileset dir="${project.build.directory}/classes" />
<!-- Adds the dependencies to jar -->
<fileset dir="${project.build.directory}/lib/" includes="*.jar" />
<application name="${project.name}" mainClass="com.google.code.mzplay.principal.PrincipalFX" />
<resources>
<!-- Adds the dependencies to classpath -->
<fileset dir="${project.build.directory}/lib/" includes="*.jar" />
</resources>
</jfxjar>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ant-javafx</artifactId>
<version>${javafx.version}</version>
<systemPath>${java.home}/../lib/ant-javafx.jar</systemPath>
<scope>system</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>${javafx.version}</version>
<systemPath>${java.home}/lib/jfxrt.jar</systemPath>
<scope>system</scope>
</dependency>
</dependencies>
</plugin>
你怎麼把依賴罐子裏面甚至不知道嗎? – jewelsea
在那裏,編輯它以顯示'pom.xml'的ant部分。當然,我首先使用'maven-dependency-plugin'將jar複製到lib文件夾中。 – Montolide
看看[使用Maven封裝JavaFX應用的此線程](https://forums.oracle.com/forums/thread。 jspa?threadID = 2442108),看看它是否有幫助。 – jewelsea