I want to ask if there is any method to add JavaFX into Maven Archetype list in Eclipse or any plugin to use Maven to build JavaFX Application.
问题:
回答1:
There is the javafx-maven-plugin which is available for maven.
When developing with Java 8 you just put that plugin as some build-plugin, without further dependencies.
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<mainClass>your.main.class.which.extends.javafx.Application</mainClass>
</configuration>
</plugin>
Calling mvn jfx:jar
creates your javafx-application-jar inside target/jfx/app/yourapp-jfx.jar
, or even creates native launcher (like EXE-file) when calling mvn jfx:native
.
Disclaimer: I'm the maintainer of the javafx-maven-plugin.
回答2:
The only thing I add to my pom.xml
in order to build JavaFX Application is this dependency :
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>2.2</version>
<systemPath>${java.home}/lib/ext/jfxrt.jar</systemPath>
<scope>system</scope>
</dependency>
It is simply fetching the javafx jar in my Java8 JRE to add it to the project.
Then I use the maven-assembly-plugin
to build the jar with dependencies.
Hope it helps.
回答3:
just do as a common Java application because JavaFX version jumped to 8.0. Supports for JavaFX are built-in.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>run application</id>
<phase>package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>cn.keepfight.intro.FXParamApp</mainClass>
<arguments>
<!--<argument>-Dsun.java2d.opengl=true</argument>-->
</arguments>
</configuration>
</execution>
</executions>
</plugin>