0

I am working on a Javafx application. I created the jar with intellij and artifact. The jar works very well on Windows. However when I run it on linux it displays this error message:

Erreur : impossible to find or load the main class view.View
Caused by : java.lang.NoClassDefFoundError: javafx/application/Application

It's probably a stupid mistake but I've been stuck on it for a long time..... I haven't found anything on the internet that could help me so if you have an idea or a useful link I'm very interested

fabian
  • 80,457
  • 12
  • 86
  • 114
Jhon Snow
  • 67
  • 1
  • 6

2 Answers2

2

You most likely are missing an implementation of JavaFX. On most Linux distributions JavaFX is packages separate from the JDK. The package is most likely called openjfx or something similar.

If you are using Debian or a Debian based distribution such as Ubuntu you should be able to install openjfx by running:

$ sudo apt-get install openjfx

1

As you already said that the Jar is working correctly on Windows, so it is packaged ok.

The only thing that might be going wrong on Linux may be one of below:

  1. you made a mistake with the classname argument
  2. the application's classpath is incorrectly specified
  3. the wrong directory is on the classpath
  4. the subdirectory path doesn't match the FQN
  5. dependencies missing from the classpath
  6. the class has been declared in the wrong package

There can be also version mismatch

Type the following on your terminal -

javac -version

If you get javac 1.6.0_10 or later as the output then you will have to do the following steps. If you dont get the above output, you will have to un-install and re-install java.

Steps to do if version shown is 1.6.0_10 or later Create symlink-

ln -s /usr/local/java /usr/local/jdk1.6.0_10

Once that is done, add the following to your .bashrc file

export JAVA_HOME=/usr/local/jdk1.6.0_10 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib

For Ref:

Vishwa Ratna
  • 5,567
  • 5
  • 33
  • 55