我添加了另一个答案,因为它很长,它显示了我如何生成签名的 jar 和 JNLP webstart 文件。
因此,首先我创建了一个能够对 jar 进行签名的证书(您将被要求输入一些信息,我使用“superpass”作为密码,看看它在 pom 中的使用位置):
cd src/main/java
mkdir jnlp
cd jnlp
keytool -genkey -alias signFiles -keystore keystore.jks
然后我使用这个 pom.xml(它有一个父 pom,但它不包含任何与 javafx 相关的内容):
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>testfx</artifactId>
<groupId>ch.pgras</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>ch.pgras</groupId>
<artifactId>hellofx</artifactId>
<version>1.0-SNAPSHOT</version>
<name>hellofx</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>2.0</version>
<systemPath>${javafx.rt.jar}</systemPath>
<scope>system</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<configuration>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<target>
<taskdef name="jfxdeploy" classname="com.sun.javafx.tools.ant.DeployFXTask"
classpathref="maven.plugin.classpath"/>
<taskdef name="jfxsignjar" classname="com.sun.javafx.tools.ant.FXSignJarTask"
classpathref="maven.plugin.classpath"/>
<jfxdeploy width="800" height="600" outdir="${project.build.directory}/deploy"
outfile="${project.build.finalName}">
<info title="${project.name}"/>
<application name="${project.name}" mainclass="webmap.WebMap"/>
<resources>
<fileset dir="${project.build.directory}" includes="*.jar"/>
<fileset dir="${project.build.directory}/dependency"
includes="*.jar"/>
</resources>
<platform javafx="2.0">
<jvmarg value="-Xms64m"/>
<jvmarg value="-Xmx256m"/>
</platform>
</jfxdeploy>
<jfxsignjar destdir="${project.build.directory}/deploy"
keystore="${project.basedir}/src/main/java/jnlp/keystore.jks"
storepass="superpass" alias="signFiles" keypass="superpass">
<fileset dir="${project.build.directory}/deploy" includes="*.jar"/>
</jfxsignjar>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.oracle.javafx</groupId>
<artifactId>ant-javafx</artifactId>
<version>2.0</version>
<systemPath>${ant.javafx.jar}</systemPath>
<scope>system</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
最后我运行 mvn install,结果将在 target/deploy...
祝你好运 :)