INF112 OpenJFX + Maven template
Simple skeleton with JavaFX.
Maven Setup
This project comes with a working Maven pom.xml
file. You should be able to import it into Eclipse using File → Import → Maven → Existing Maven Projects (or Check out Maven Projects from SCM to do Git cloning as well). You can also build the project from the command line with mvn clean compile
and test it with mvn clean test
.
Pay attention to these folders:
-
src/main/java
– Java source files go here (as usual for Maven) -
src/main/resources
– data files go here, for example in anassets
sub-folder -
src/test/java
– JUnit tests -
target/classes
– compiled Java class files
You should probably edit the pom.xml
and fill in details such as the project name
and artifactId
:
< !-- FIXME - set group id -->
<groupId>inf112.skeleton.app</groupId>
< !-- FIXME - set artifact name -->
<artifactId>javafx-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
< !-- FIXME - set app name -->
<name>mvn-app</name>
< !-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
Running
You can run the project from Eclipse, or with Maven using mvn javafx:run
. Change the main class by modifying the main.class
setting in pom.xml
:
<main.class>inf112.skeleton.app.Main</main.class>
Jar Files
If you run mvn package
you get everything bundled up into a .jar
file + a ‘fat’ Jar file where all the necessary dependencies have been added:
-
target/NAME-VERSION.jar
– your compiled project, packaged in a JAR file -
target/NAME-VERSION-fat.jar
– your JAR file packaged with dependencies
Run Jar files with, for example, java -jar target/javafx-app-1.0-SNAPSHOT-fat.jar
.
Eclipse Setup
It's usually smart to change Eclipse's Maven settings so that it'll automatically download Javadocs and the source code for your dependencies: