Search code examples
javajavafxjarexecutable-jarapache-commons-compress

The jar libs\commons-compress-1.18.jar has a main class org.apache.commons.compress.archivers.Lister that does not match the declared main


I am developing a Javafx application and its ready for the build. In order to read and write excel files I,m using org.apache.commons.compress library (a jar file), which has a main class named Lister in it. Where as, my application has its own MainApp class file (essential for a Javafx application). So, while I'm building the application, the build is successful and a jar file of my application is also generated but I am getting this error :

The jar libs\commons-compress-1.18.jar has a main class  
org.apache.commons.compress.archivers.  
Lister that does not match the declared main org.dracul.tree.MainApp
Bundler EXE Installer skipped because of a configuration problem: Main application jar is missing.  

This means that there are two main files inside my jar.

Secondly, when I'm running executable jar of my application, it crashes.


Solution

  • You can specify main class when creating the jar, by adding class name as MyClass:

    java -cp myjar.jar MyClass