Git Product home page Git Product logo

java9-workshop-jlink's Introduction

JLink example

This is a minimal example of an application that can be modularized using JLink and distributed with it's own JRE containing only the required Java modules and this application.

Structure

The maven project has two modules to emulate a real modular application. The api module contains a Student class representing the API. The app module contains a Main class that instansiates three student objects and prints the information to System.out when run. This is supposed to emulate the main application that would start an application server and run a real application.

Setup

Make sure you are using Java 12

  • java -version and mvn -version should both show some Java 12 version/build

Build the modular jars

mvn clean install

Create a temp folder

mkdir libs

Copy the modular jars to libs folder

cp api/target/jlink-api-1.0-SNAPSHOT.jar libs/

cp app/target/jlink-app-1.0-SNAPSHOT.jar libs/

Create the JRE using jlink

Remember to change the below path to the JDK to something that matches your installation location.

jlink --module-path "/c/java/jdk-12/jmods/;libs" --add-modules no.hamre.java9workshop.jlink.api,no.hamre.java9workshop.jlink.app --output image/

This will create the custom JRE with the application in the image folder

Run the application from your JRE

cd image

./bin/java -m no.hamre.java9workshop.jlink.app/no.hamre.java9workshop.jlink.app.Main

Using the maven-jlink-plugin

Chekout the branch maven-plugin.

Here we are using maven-jlink-plugin to build the JRE. With this plugin the maven project has a new module, image, used only for building the JRE from the other two modules using the plugin.

java9-workshop-jlink's People

Contributors

javaguruen 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.