Coder Social home page Coder Social logo

java-9-maven-template's Introduction

Java 9 & Maven template for building JAR with dependencies inside

Simple template for Java 9 & Maven for building JAR with dependencies inside

Getting started

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

Magic with pom.xml

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>

Build

Make JAR

mvn package

Run

cd target && java -jar appId-1.0-jar-with-dependencies.jar 

Tested on

  • MacOS Sierra

java-9-maven-template's People

Contributors

icune avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.