简体   繁体   中英

How to recompile and launch Java FX application with Maven and Intell IJ idea?

In tutorial for Java FX application with Maven, only following code was in pom.xml :

<?xml version="1.0" encoding="UTF-8"?>
<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">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>example_artefact_id</artifactId>
  <version>1.0-SNAPSHOT</version>

  <build>
    <plugins>

      <plugin>
        <groupId>com.zenjava</groupId>
        <artifactId>javafx-maven-plugin</artifactId>
        <version>2.0</version>
        <configuration>
          <mainClass>com.example.App</mainClass>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

If to run Run Maven build in IntelliJ IDEA, it will finish with BUILD SUCCESS message. First what I did not understand: what is next? No app that could be started.

I found some info that it's required to create the jar by the following plugin:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.5</version>
    <configuration>
      <archive>
        <manifest>
          <mainClass>jp.co.yd.App</mainClass>
        </manifest>
      </archive>
    </configuration>
  </plugin>

Is far as I understand, after editing code it's require to recompile app, create new jar and start it. How I should to setup IntelliJ IDEA to do above action at once?

This is a maven project , so to create the jar you only need to put

<packaging>jar</packaging>

execute

mvn clean install

and you'll find the .jar in the Target File

you can after that use this jar to run your javaFx jar using :

java -jar jarName.jar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM