2

This question already has an answer here:

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 some form of the error that it can't find my Main class. Javac also doesn't work, getting the same kind of error there. 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. Any ideas?

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

After installing javafx, which is necessary as some people pointed out, it still doesn't work. Running the java command gives the same (see above). Here are some examples of running the javac command:

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

marked as duplicate by Kulfy, Charles Green, user68186, Elder Geek, Luis Alvarado Mar 6 at 21:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Don't give us your vague paraphrased error "something or other can't find..." this isn't helpful. Post the full error – j-money Mar 5 at 11:10
  • @j-money It didn't tell me much, that's why I didn't include it. But I've put it in now. – Luctia Mar 5 at 11:50
  • This one was my mistake, can you also post the command used to generate said error? – j-money Mar 5 at 11:51
  • JavaFX is not installed by default. See karel's answer in the above question. Or simply run sudo apt install openjfx – Kulfy Mar 5 at 11:58
  • @Kulfy good point, hadn't done that yet. The installation was succesfull, but sadly didn't fix the issue. I'm still getting the same error. – Luctia Mar 5 at 12:16
0

I assume you use Ubuntu 18.04 or Ubuntu 18.10. They have Java 11 as default-jre. Java 11 does not have Java FX. You have to install separate Java FX runtime on Ubuntu or pack all necessary libraries (modules) of Java FX inside your app with Maven or Gradle. For the packing you need to make the build inside Linux (Ubuntu) because then Maven/Gradle will download the lib for Linux. Yes the build is per OS.

More info: https://stackoverflow.com/questions/52013505/how-do-i-use-javafx-11-in-eclipse/52015953#52015953

More information about Java FX 11: https://openjfx.io/openjfx-docs/#install-java

If your app is made with Java 8 (Java 1.8) containing Java FX and you do not want to change to Java 11 then you need to install Open Java 8 on your Ubuntu + install openjfx

Another solution will be to install Oracle Java 8 for Ubuntu which will contain JavaFx.

More information how to install java: https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-18-04

I hope I help.

Best luck to all!

Not the answer you're looking for? Browse other questions tagged or ask your own question.