You are not logged in.

#1 2019-12-02 11:59:00

imroroyo
Member
Registered: 2019-12-02
Posts: 1

Can't run .jar file including javafx

Hello, as a part of a project at university I am trying to run a .jar file including some javafx-gui that one of the project members did. I can't quite get it to work though.

This is the command I run, and output:

[user@pc ~/Downloads]$ java -jar CC_panel.jar
Error: Could not find or load main class CCPanel
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

The .jar file works fine on other members' computers.

Here you can see my java environments:

[user@pc ~/Downloads]$ archlinux-java status
Available Java environments:
  java-13-jdk
  java-13-openjdk (default)

And here are my java-related packages.

[user@pc ~/Downloads]$ p -Qs java
local/ca-certificates-utils 20181109-2
    Common CA certificates (utilities)
local/java-environment-common 3-1
    Common files for Java Development Kits
local/java-openjfx 13.u14-1
    Java OpenJFX 13 client application platform (open-source implementation of JavaFX)
local/java-runtime-common 3-1
    Common files for Java Runtime Environments
local/jdk 13.0.1-1
    Oracle Java Development Kit
local/jre 13.0.1-1
    Oracle Java Runtime Environment
local/jre-openjdk 13.0.1.u9-1
    OpenJDK Java 13 full runtime environment
local/jre-openjdk-headless 13.0.1.u9-1
    OpenJDK Java 13 headless runtime environment
local/js60 60.9.0-1
    JavaScript interpreter and libraries - Version 60
local/mujs 1.0.6-1
    An embeddable Javascript interpreter in C

Very confused about what's going on here, would appreciate some help!

Offline

#2 2019-12-02 21:24:03

Bevan
Member
Registered: 2009-09-08
Posts: 55

Re: Can't run .jar file including javafx

I guess the application is developed with Java 8 in mind. Probably one of the following approaches will help you:

1. Install `java8-openjfx` and then run the application as follows:

/usr/lib/jvm/java-8-openjdk/bin/java -jar CC_panel.jar

2. Install `java-openjfx` and then run the application as follows:

/usr/lib/jvm/java-13-openjdk/bin/java --module-path /usr/lib/jvm/java-13-openjdk/lib/javafx.base.jar:/usr/lib/jvm/java-13-openjdk/lib/javafx.controls.jar:/usr/lib/jvm/java-13-openjdk/lib/javafx.fxml.jar:/usr/lib/jvm/java-13-openjdk/lib/javafx.graphics.jar:/usr/lib/jvm/java-13-openjdk/lib/javafx.media.jar:/usr/lib/jvm/java-13-openjdk/lib/javafx.swing.jar:/usr/lib/jvm/java-13-openjdk/lib/javafx.web.jar:/usr/lib/jvm/java-13-openjdk/lib/javafx-swt.jar:/usr/lib/jvm/java-13-openjfx/lib/javafx.base.jar:/usr/lib/jvm/java-13-openjfx/lib/javafx.controls.jar:/usr/lib/jvm/java-13-openjfx/lib/javafx.fxml.jar:/usr/lib/jvm/java-13-openjfx/lib/javafx.graphics.jar:/usr/lib/jvm/java-13-openjfx/lib/javafx.media.jar:/usr/lib/jvm/java-13-openjfx/lib/javafx.swing.jar:/usr/lib/jvm/java-13-openjfx/lib/javafx.web.jar:/usr/lib/jvm/java-13-openjfx/lib/javafx-swt.jar --add-modules ALL-MODULE-PATH -jar CC_panel.jar

The second option will attempt to run the program with Java 13. Since JavaFX is no part of the JDK anymore, you need to explicitly specify the module path in this case, which leads to the rather convoluted command shown above.

Offline

Board footer

Powered by FluxBB