1

I know that there are a lot of posts on SOF regarding this same topic , but I feel my problem is a little different.

I have a maven based java project which uses javaFx . Need to create an executable jar file and run it from the command line or on double click of the jar file.

This is how I build it , the relevant portion of my pom.xml file is this

 <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
      <configuration>
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
        <archive>
          <manifest>
           <addClasspath>true</addClasspath>
            <mainClass>com.sumanta.MyMain</mainClass>
          </manifest>

          <manifestEntries>
           <Class-Path>./</Class-Path>
          </manifestEntries>
        </archive>
      </configuration>
   </plugin>

I then use maven to build the executable jar using this

clean compile assembly:single

I am using eclipse IDE .

The jar file that is created runs on windows 8 on double click and from the command line.

Now I need this to run on ubuntu linux as well . I have Open JDK 8 installed my linux installation but when I double click on the jar file nothing happens.

Then I open up the terminal and give this command

  java -jar myExecutableJarFile.jar

I am getting this error

  Error: Could not find or load main class com.sumanta.MyMain

It seems to be a problem with the manifest file . This file lists the proper name along with the full package path of the class which contains the main method

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: Ayan
Build-Jdk: 1.8.0_71
Main-Class: com.sumanta.MyMain
Class-Path: ./

What is wrong with this setup . I need the application to run on windows , linux , and mac OS. I suppose since mac and linux are unix type Os , if the application runs on linux it will run on mac os as well .

  • On Linux, verify that you're able to run the jar file by directly running the main class and including the JAR in the classpath `java -cp ".;myExecutableJarFile.jar" com.sumanta.MyMain` – 11thdimension Jul 28 '17 at 13:51
  • 1
    Possible duplicate of [JavaFX: Could not find or load main class only on linux](https://stackoverflow.com/questions/37344984/javafx-could-not-find-or-load-main-class-only-on-linux) – Itai Jul 28 '17 at 14:00
  • Many Linux distributions package JavaFX separately from the rest of the JRE. See linked question. – Itai Jul 28 '17 at 14:01
  • What does `unzip -v myExecutableJarFile.jar | grep MyMain` show? – VGR Jul 28 '17 at 14:12
  • There are 2 files ie MyMain.java and MyMain.class file within com/sumanta folder within the unzipped root folder – Indronil Chaudhuri Jul 29 '17 at 13:58
  • @IndronilChaudhuri That shows there is a problem with your build cause source files do not belong into the JAR file at all... – khmarbaise Jul 30 '17 at 13:08
  • I am using maven for the build , it seems my build is wrong can you tell me what exactly is wrong with the process I follow to build the project with maven. – Indronil Chaudhuri Jul 31 '17 at 10:29

0 Answers0