Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用IntelliJ IDEA导出JAR(JavaFX和Maven)_Java_Maven_Intellij Idea_Javafx_Deeplearning4j - Fatal编程技术网

如何使用IntelliJ IDEA导出JAR(JavaFX和Maven)

如何使用IntelliJ IDEA导出JAR(JavaFX和Maven),java,maven,intellij-idea,javafx,deeplearning4j,Java,Maven,Intellij Idea,Javafx,Deeplearning4j,我使用pom.xml为Maven创建了一个新的JavaFX项目。现在我想把它导出到一个可运行的JAR。目前,我正在使用IntelliJ IDEA 2017.1.1-2 你会怎么做 这是我当前的pom.xml: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://m

我使用pom.xml为Maven创建了一个新的JavaFX项目。现在我想把它导出到一个可运行的JAR。目前,我正在使用IntelliJ IDEA 2017.1.1-2

你会怎么做

这是我当前的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/xsd/maven-4.0.0.xsd">

    <groupId>org.drawpvp</groupId>
    <artifactId>drawpvp</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <modelVersion>4.0.0</modelVersion>


    <name>DrawPVP</name>
    <description>Competitive drawing game.</description>
    <properties>
        <!-- Change the nd4j.backend property to nd4j-cuda-7.5-platform or nd4j-cuda-8.0-platform to use CUDA GPUs -->
        <nd4j.backend>nd4j-native-platform</nd4j.backend>

        <java.version>1.8</java.version>
        <nd4j.version>0.8.0</nd4j.version>
        <dl4j.version>0.8.0</dl4j.version>
        <datavec.version>0.8.0</datavec.version>
        <arbiter.version>0.8.0</arbiter.version>
        <rl4j.version>0.8.0</rl4j.version>

    </properties>

    <repositories>
        <repository>
            <id>snapshots-repo</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <distributionManagement>
        <snapshotRepository>
            <id>sonatype-nexus-snapshots</id>
            <name>Sonatype Nexus snapshot repository</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>nexus-releases</id>
            <name>Nexus Release Repository</name>
            <url>http://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.nd4j</groupId>
                <artifactId>nd4j-native-platform</artifactId>
                <version>${nd4j.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- ND4J backend. You need one in every DL4J project. Normally define artifactId as either "nd4j-native-platform" or "nd4j-cuda-7.5-platform" -->
        <dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>${nd4j.backend}</artifactId>
        </dependency>

        <!-- Core DL4J functionality -->
        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-core</artifactId>
            <version>${dl4j.version}</version>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.0.13</version>
        </dependency>

        <dependency>
            <groupId>com.jfoenix</groupId>
            <artifactId>jfoenix</artifactId>
            <version>1.3.0</version>
        </dependency>

        <dependency>
            <groupId>org.datavec</groupId>
            <artifactId>datavec-api</artifactId>
            <version>${datavec.version}</version>
        </dependency>


</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>com.zenjava</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>8.8.3</version>
            <configuration>
                <mainClass>gui.Main</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

org.drawpvp
drawpvp
0.0.1-快照
4.0.0
DrawPVP
竞争性绘图游戏。
nd4j本机平台
1.8
0.8.0
0.8.0
0.8.0
0.8.0
0.8.0
快照回购
https://oss.sonatype.org/content/repositories/snapshots
假的
真的
sonatype nexus快照
Sonatype Nexus快照存储库
https://oss.sonatype.org/content/repositories/snapshots
nexus发布
Nexus发布库
http://oss.sonatype.org/service/local/staging/deploy/maven2/
org.nd4j
nd4j本机平台
${nd4j.version}
org.nd4j
${nd4j.backend}
org.deeplearning4j
深度学习4J型芯
${dl4j.version}
回写
回归经典
1.0.13
com.jfoenix
杰福尼克斯
1.3.0
org.datavec
datavec api
${datavec.version}
com.zenjava
javafxmaven插件
8.8.3
gui.Main
如何为此导出JAR?

假设您修改pom.xml中的
标记,如下所示

<build>
        <plugins>
            <plugin>
                <groupId>com.zenjava</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>8.8.3</version>
                <configuration>
                    <mainClass>gui.Main</mainClass>
                </configuration>
            </plugin>
             <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <configuration>
            <archive>
              <manifest>
                <mainClass>org.drawpvp.MainClass</mainClass>
              </manifest>
            </archive>
            <descriptorRefs>
              <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>
          </configuration>
        </plugin>
        </plugins>
    </build>

com.zenjava
javafxmaven插件
8.8.3
gui.Main
maven汇编插件
org.drawpvp.MainClass
带有依赖项的jar

免责声明:我是javafx maven插件的维护者

要执行javafx maven插件,您有两个选项:

  • 将其称为正常maven生命周期的一部分
    mvn包
  • 直接从插件的cli/IDE目标
    jar
    调用它
  • 在使用选项1(maven生命周期)时使用此选项:

    
    com.zenjava
    

    假设您在
    drawpvp
    下面添加
    jar
    ,并运行maven Install,尝试运行在
    target
    文件夹中创建的.jar后返回一个
    无主清单属性的错误。@JadenWang请查看我的答案,如果您想使用javafxmaven,它可能会对您有更多帮助-plugin@FibreFoX与使用插件相比,我当前的pom.xml有哪些缺点?使用
    maven汇编插件
    并不能解决问题,使用
    javafxmaven插件时,除了“只需创建一些可执行的jar”之外,您还可以创建本机二进制文件和安装程序,并为几个
    javapackager
    错误提供了一些解决方法,但是现在它似乎没有拾取依赖项,因为它抛出了一堆依赖项错误。你能提取jar并查看是否包含jar吗,它不包括我正在使用的库。参考这个,这可能有解决方案。@JadenWang也修改了解决方案。执行时,您可以调用
    mvn package
    ,而不必调用github项目中描述的
    mvn jfx:jar
    。我尝试了很多次,但运气都不好。它一启动就会崩溃。它也没有在jar中存储依赖项。我回家后会给你打电话。@JadenWang如果你需要进一步的帮助,请直接通过电子邮件与我联系;)永远在那里help@FibreFoX请随意更正我的解决方案。我们都在学习。谢谢。@RajithPemabandu javafx可执行JAR包含一个
    类路径
    -条目、一个正常的
    主类
    -条目和一个
    权限
    -条目,JDK包含一个名为
    javapackager
    的工具,javafx maven插件使用该工具。您的解决方案是针对“普通jar可执行文件”,它们的工作方式确实有点不同,因此调整您的解决方案不适合javafx
    <plugin>
        <groupId>com.zenjava</groupId>
        <artifactId>javafx-maven-plugin</artifactId>
        <version>8.8.3</version>
        <configuration>
            <mainClass>gui.Main</mainClass>
        </configuration>
        <executions>
            <execution>
                <id>create-jfxjar</id>
                <phase>package</phase>
                <goals>
                    <goal>build-jar</goal>
                </goals>
            </execution>
        </executions>
    </plugin>