通过Maven使用JavaFX构建可执行文件.jar

时间:2019-09-20 16:29:06

标签: java maven javafx jar

所有人!

我已经尝试根据this post由Maven创建依赖JavaFX的.jar文件。不幸的是,尝试失败了。在文件夹targets中创建两个文件:

  • MAVEN_UI_INTRO-1.0-SNAPSHOT.jar
  • 原始MAVEN_UI_INTRO-1.0-SNAPSHOT.jar 对于第一个文件,我得到此错误: Error: JavaFX runtime components are missing, and are required to run this application 对于第二个文件,此错误: no main manifest attribute, in target/original-MAVEN_UI_INTRO-1.0-SNAPSHOT.jar

通过命令mvn clean package

构建

通过命令java -jar target/"someJarFile.jar"

启动

主要问题:我怎么了?

UPD:我的pom.xml文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.novalab</groupId>
    <artifactId>MAVEN_UI_INTRO</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>11.0.2</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.novalab.App</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.1</version>
                <configuration>
                    <mainClass>com.novalab.App</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

0 个答案:

没有答案