Simple template for Java 9 & Maven for building JAR with dependencies inside
Example project for making plot with jFreeChart
All directory structure is generated by
mvn -B archetype:generate \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DgroupId=app \
-DartifactId=appId
from https://maven.apache.org/guides/getting-started/index.html tutorial
then added Plot class, compiled from StackOverflow answer https://stackoverflow.com/a/16718736
In pom.xml add jFreeChart
<dependencies>
...
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.19</version>
</dependency>
</dependencies>
Also insert Java 9 Maven support
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
Then add maven-assembly-plugin configuration compiled from answer StackOverflow answer https://stackoverflow.com/a/1729202
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>bundle</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>app.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Make JAR
mvn package
Run
cd target && java -jar appId-1.0-jar-with-dependencies.jar
- MacOS Sierra