1

I'm currently trying to port my project to javafx11. For testing, I'm trying to create a runnable jar file with the hello-world-example from the tutorial page. I included the vm-modules, to prevent the error Error: JavaFX runtime components are missing, and are required to run this application.

In eclipse, everything works fine, but when I export the project as a runnable jar file, the error returns when I try to run the jar.

When I export the jar-file, I choose the same run configuration as the app and I chose to extract required libraries into generated jar.

EDIT: As it was recommended, I'm currently trying to create a runnable jar with maven. The bhild succeds, but I can't execute it.

The pom.xml looks like this

<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>Mpp_App</groupId>
  <artifactId>Mpp_App</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>Dacemo</name>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <resources>

      <resource>
        <directory>src</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <release>11</release>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-maven-plugin</artifactId>
        <version>0.0.2</version>
        <configuration>
            <mainClass>Start</mainClass>
        </configuration>
        </plugin>
        <plugin>
        <!-- Build an executable JAR -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>Start</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>

  </build>

  <dependencies>
    <dependency>
        <groupId>com.jfoenix</groupId>
        <artifactId>jfoenix</artifactId>
        <version>9.0.8</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>itextpdf</artifactId>
        <version>5.5.13</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
    <dependency>
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>1.1.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox -->
    <dependency>
        <groupId>org.apache.pdfbox</groupId>
        <artifactId>pdfbox</artifactId>
        <version>2.0.15</version>
    </dependency>

  </dependencies>
</project>

On trying to execute it, I get the error

Could not find or laod main class Start
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

Is the Start.java defined wrongly? In the eclipse project structure, the Start.java lies in the default package.

Lenny Will
  • 549
  • 1
  • 4
  • 11
  • As the error says, your jar is missing the JavaFX library. JavaFX is *not* bundled with the JVM. You need to add that library to your build. For more help, give more details. For example, if using Maven, post your POM. – Basil Bourque May 26 '19 at 11:38
  • @BasilBourque Thanks for the quick response: I'm not using Maven, I'm using plain Java. I have added the javafx12 library as a user library to the build and I'm using java 12 – Lenny Will May 26 '19 at 11:46
  • Duplicated of [JAR File Creation in JDK 11 and JavaFx](https://stackoverflow.com/questions/53638371/jar-file-creation-in-jdk-11-and-javafx), however, there is no accepted answer. You can see the edit to understand how it was solved (via command line). In case you are using Maven or Gradle that would be easier. See this [answer](https://stackoverflow.com/questions/55300695/jdk11-javafx-how-do-i-make-a-fat-jar-without-build-depdency-management/55303408#55303408) too. – José Pereda May 26 '19 at 11:48
  • @LennyWill Have you unzipped one of your jars to verify the JavaFX library is actually present, and located in the correct folder? Perhaps you should display that file-folder listing in your Question. – Basil Bourque May 26 '19 at 12:02

0 Answers0