0

I know how to create an executable jar in Maven with Spring Boot.

I also know how to integrate JavaFX with Spring Boot. Tutorial

The question is how do I package a jvm and all dependencies so they all run as an executable in the Rasbian os of the Raspberry Pi 3b+ (latest as of 12/1/2018).

Alternatively if this is not possible - how do you go about configuring maven to include all javafx dependencies such as javafx jdk and gluon javafxports (which are required as I understand).

Thanks

Here is my example pom.xml - it runs fine on windows - does not work in Rasbian

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>rx7.electrical.system</groupId>
    <artifactId>oces</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>oces</name>
    <description>Rx7 Onboard Computer Electrical System</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.0.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.jfoenix/jfoenix -->
        <dependency>
            <groupId>com.jfoenix</groupId>
            <artifactId>jfoenix</artifactId>
            <version>8.0.7</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/de.jensd/fontawesomefx -->
        <dependency>
            <groupId>de.jensd</groupId>
            <artifactId>fontawesomefx</artifactId>
            <version>8.9</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.openjfx/javafx-base -->
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-base</artifactId>
            <version>12-ea+3</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.javafxports/armv6hf-sdk -->
        <dependency>
            <groupId>org.javafxports</groupId>
            <artifactId>armv6hf-sdk</artifactId>
            <version>8.60.11</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <executable>true</executable>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>rx7.onboard.computer.electrical.system.main.App</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
Edv Beq
  • 910
  • 3
  • 18
  • 43
  • It seems you are targeting Java 8. Your dependencies for JavaFX 12 won't work. The `armv6hf-sdk` artifact contains the JavaFX SDK for ARM on 8, but you'll need to install it, as explained [here](https://stackoverflow.com/a/40483500/3956070), into the existing JDK 1.8 in your Pi. Then that JDK should be able to run your jar. – José Pereda Dec 02 '18 at 11:13
  • @JoséPereda Yes I was targeting Java 8 because JavaFX is still included. I will try your instructions tonight. My question still stands tho - is it possible to build a self containing jar like one can do with the pure JavaFX fxbuild? – Edv Beq Dec 03 '18 at 12:00
  • There is a way to run JavaFX embedded with a Java 11 distribution for ARM, see this [post](http://docs.gluonhq.com/embedded/). That will let you use a "semi" fat jar (all dependencies but JavaFX). With some work you might be able to add those JavaFX jars to the full fat jar. See [docs](https://openjfx.io/openjfx-docs/#modular), section non-modular projects. – José Pereda Dec 03 '18 at 12:12
  • @JoséPereda Thank you for the info. Will give it a try and update my post here. – Edv Beq Dec 03 '18 at 12:16
  • @JoséPereda I was able to create a fat jar and run the application on the pi with Java 11. For runtime I installed Liberica JDK 11 from Bellsoft. So one more step - how do I include the java runtime in maven - since the javafx runtime is sorted. – Edv Beq Dec 04 '18 at 10:55

0 Answers0