简体   繁体   中英

Errors running JavaFX .jar file on Ubuntu

I'm trying to make the JavaFX application I made on Windows work for Ubuntu. I've made the .jar file and it works fine on Windows 10, but won't work on Ubuntu. Whether I double click it from the desktop (with running as executable enabled) or run it from the terminal, I keep getting these errors:

javac myApp.jar or javac myApp

error: Class names, 'myApp.jar', are only accepted if annotation processing is explicitly requested

javac -cp myApp.jar or javac -cp myApp

javac: no source files

This is the error I get on running java -jar myApp.jar:

Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: javarx/application/Application

This is my MANIFEST file:

Manifest-Version: 1.0
Implementation-Title: 
Implementation-Version: 
Permissions: sandbox
JavaFX-Version: 8.0
Class-Path: 
Created-By: JavaFX Packager
Implementation-Vendor: 
Main-Class: Main

I have installed Java using the apt install default-jre command. I've also installed JavaFX.

I think it might be some issue with where the application tries to get its JavaFX library from, but I'm not sure whether this is it or how I'd fix it.

default-jre package will install Open JDK 11 in Ubuntu Bionic. Java 11 removed JavaFX from the default distribution . This binaries are now shipped separately outside of the JDK, you can get them from Maven Central .

Either downgrade to a lower version of JRE/JDK or repackage the application to include the JavaFX binaries so it can work with Java 11.

Apparently in order to get JavaFX with your Java distribution, you have to download it form Oracle instead of the regular openjdk-8-jre. I got my solution from this website . Thanks to everyone who helped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM