0

Creating JAR is going wrong with JDK 11 and JavaFX dependencies. Fat JAR is building, but execution is not working, see error below...

This is my MANIFEST.MF:


Manifest-Version: 1.0
Created-By: Apache Maven 3.5.4
Built-By: gerri
Build-Jdk: 11.0.1
Class-Path: javax.json-api-1.1.2 tornadofx-1.7.17 kotlin-reflect-1.2.60 
 kotlin-stdlib-1.3.0-rc-198 kotlin-stdlib-common-1.3.0-rc-198 kotlin-std
 lib-jdk7-1.2.60 kotlin-stdlib-jdk8-1.2.60 javax.json-1.1.2 annotations-
 13.0
Main-Class: de.auticon.maven.tornadofx.MainAppKt

P. S. I want to package JAR with maven3, b/c with IntelliJ IDEA it is not running, too!

Updated pom.xml as requested:


<?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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>de.auticon.maven.tornadofx</groupId>
    <artifactId>de-auticon-maven-tornadofx</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>de.auticon.maven.tornadofx de-auticon-maven-tornadofx</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <kotlin.version>1.3.0-rc-198</kotlin.version>
        <kotlin.code.style>official</kotlin.code.style>
        <junit.version>4.12</junit.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-test-junit</artifactId>
            <version>${kotlin.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>no.tornado</groupId>
            <artifactId>tornadofx</artifactId>
            <version>1.7.17</version>
        </dependency>

        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>11-ea+19</version>
        </dependency>

    </dependencies>

    <build>
        <sourceDirectory>src/main/kotlin</sourceDirectory>
        <testSourceDirectory>src/test/kotlin</testSourceDirectory>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <archive>
                        <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>

            </plugin>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <configuration>
                    <jvmTarget>1.8</jvmTarget>
                </configuration>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <!-- get all project dependencies -->
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <!-- MainClass in mainfest make a executable jar -->
                    <archive>
                      <manifest>
                        <mainClass>de.auticon.maven.tornadofx.MainAppKt</mainClass>
                      </manifest>
                    </archive>

                </configuration>
                <executions>
                  <execution>
                    <id>make-assembly</id>
                                        <!-- bind to the packaging phase -->
                    <phase>package</phase> 
                    <goals>
                        <goal>single</goal>
                    </goals>
                  </execution>
                </executions>
            </plugin>


        </plugins>
    </build>

</project>

Do I really need javafxpackager as described here?

FatJAR is building, but not executing:

D:\Source\deauticonmaventornadofx\target>java -jar de-auticon-maven-tornadofx-1.0-SNAPSHOT-jar-with-dependencies.jar
Error: JavaFX runtime components are missing, and are required to run this application
Leder
  • 396
  • 1
  • 5
  • 21
  • 1
    shouldn't the entries in the MANIFEST have a `.jar` extension? – Renato Nov 14 '18 at 12:43
  • 2
    I would suggest you stop messing with the manifest, just create a fat jar: https://www.mkyong.com/maven/create-a-fat-jar-file-maven-assembly-plugin/ – Renato Nov 14 '18 at 12:44
  • 1
    Can you post your pom? We need to see the source to figure out where things go wrong. What version on Java? I also agree that you should consider a fat jar. – Edvin Syse Nov 14 '18 at 13:03
  • yes, `.jar` was missing, now I have to add javafx library to `pom.xml` – Leder Nov 14 '18 at 13:09
  • `D:\Source\deauticonmaventornadofx\target>javac -version javac 11.0.1` – Leder Nov 14 '18 at 13:58
  • 2
    TornadoFX is not yet compatible with Java 11, you have to use Java 8. We're working on Java 11 support and it should be ready soon. – Edvin Syse Nov 14 '18 at 14:12
  • Yes, fat JAR is building and running with JDK 8. Please add an answer, so I can accept it. – Leder Nov 14 '18 at 15:06

0 Answers0