How to create an executable jar which is executable (Maven-Jfoenix-Hibernate-IntelliJ) __ Can someone makes the subject resolve/close please

I try to generate an executable jar file from a project which use : Maven, JFX, JFoenix, Hibernate ... in IntelliJ

I have tried many solution which we can found in different developer forum/website (StackOverflow included). Therefore no one works for me..

I have tried to create the executable jar file with :

  • Command : mvn compile _ which create two executable jar which execute nothing..

  • Create an artifact : File -> Save All -> Project Structure -> + -> Jar -> From modules dependacies -> Main Class : MyMainClass / Directory : src\main\java OR src\main\resources (because he worked for someone to change this.) -> Ok Build -> Build artifact -> Build OR Rebuild. At this moment i have an executable, but it execute nothing..

  • Shade plugging : (You'll see in the code of pom.xml) which give in result :
Failed to execute goal
org.apache.maven.plugins:maven-shade-plugin:3.2.1:shade (default-cli)
on project GymFormManager: Failed to create shaded artifact, project main
artifact does not exist.

pom.xml, i take only the important part because it's too huge:

...

<modelVersion>4.0.0</modelVersion>
<groupId>com.gymform.maven</groupId>
<artifactId>GymFormManager</artifactId>
<version>1.0-SNAPSHOT</version>

</dependencies>
    ...   
    <!-- Try To Create Executable Jar -->
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.1</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-utils</artifactId>
        <version>1.1</version>
    </dependency>
</dependencies>

<build>
    <plugins>

        ...

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>com.gymformmanager.Main</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.2.1</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>com.gymformmanager.Main</mainClass>
                            </transformer>
                        </transformers>

              <!-- I have tried with and without hadedArtifact -->       <shadedArtifactAttached>true</shadedArtifactAttached>
                        <shadedClassifierName>GymFormManager</shadedClassifierName> <!-- Any name that makes sense -->
                    </configuration>
                </execution>
            </executions>
        </plugin>

Currently, i have three executable jar which doing nothing :

The first executable The path of the first executable

The second and third executable Their paths

Edit: After following the advices of Jony, i have this error :

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/gymformmanager/Main has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runt
ime only recognizes class file versions up to 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

I resolved the problem of version with this : Windows ignores JAVA_HOME: how to set JDK as default?

Error: JavaFX runtime components are missing, and are required to run this application

While i have in my pom.xml the dependency :

 <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>11</version>
 </dependency>

You can try to assemble a so called fatjar with maven:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
        <archive>
            <manifest>
                <mainClass>com.gymformmanager.Main</mainClass>
            </manifest>
        </archive>
    </configuration>
    <executions>
        <execution>
            <id>assemble-all</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
 </plugin>

This will create an additional jar file in your output directory called GymFormManager-jar-with-dependencies.jar. You can run it with:

java -jar GymFormManager-jar-with-dependencies.jar

Newest 'maven' Questions - Page 167, How to create an executable jar which is executable (Maven-Jfoenix-Hibernate- IntelliJ) __ Can someone makes the subject resolve/close please � java maven� Teams. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

If you want to create an executable jar file, you need to configure Maven Archiver accordingly. You need to tell it which main class to use. This is done with the configuration element. Here is a sample pom.xml configured to add the classpath and use the class fully.qualified.MainClass as the main class:

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        ...
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
              <mainClass>fully.qualified.MainClass</mainClass>
            </manifest>
          </archive>
        </configuration>
        ...
      </plugin>
    </plugins>
  </build>
  ...
  <dependencies>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>2.1</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-utils</artifactId>
      <version>1.1</version>
    </dependency>
  </dependencies>
  ...
</project>

如何创建一个可执行的可执行文件(Maven-Jfoenix-Hibernate-IntelliJ), to create an executable jar which is executable (Maven-Jfoenix-Hibernate- IntelliJ) __ Can someone makes the subject resolve/close please. Teams. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

I guess javafx-maven-plugin is a good option to build JFX application. It is based on Java Packager Tool and can build both native bundle and jar. Call mvn jfx:jar to start building.

<plugin>
    <!-- Generate Executable JFX JAR -->
    <groupId>com.zenjava</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>8.8.3</version>
    <configuration>
        <vendor>${vendor}</vendor>
        <mainClass>${mainClass}</mainClass>
        <allPermissions>true</allPermissions>
        <manifestAttributes>
            <Implementation-Title>${project.name}</Implementation-Title>
            <Implementation-Version>${project.version}</Implementation-Version>
            <Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
            <Build-Timestamp-Format>${maven.build.timestamp.format}</Build-Timestamp-Format>
            <Build-Timestamp>${dev.build.timestamp}</Build-Timestamp>
        </manifestAttributes>
        <jfxMainAppJarName>${jfxMainAppJarName}</jfxMainAppJarName>
    </configuration>
    <executions>
        <execution>
            <id>create-jfxjar</id>
            <phase>package</phase>
            <goals>
                <goal>build-jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

How to create executable JAR using Intellij ? – IDEs Support (IntelliJ , Hi,I am using Intellij IDEA 12.1.3 on MAC OS X 10.8.3 to create an executable jar file.I go to File MF file in the jar file it indeed does not have Main-Class entry. Using Maven by adding the <build> section to pom.xml sucesfully creates working jar. Do you have a screenshot for building, please? 0. Avatar.

IntelliJ Building Jar, If I do add additional libraries, they do show inside the JAR file when I unzip it. However, my code. com.IntenseArmadillo.x does not. Please�

How can I build an executable JAR from a project (including , I was planning to create an executable JAR from a project, and was a bit surprised that this seems to be a problem in IntelliJ IDEA (I am. Set up your project as a Maven project; Add the following to your pom.xml (right "install" and check "Execute before Make" (by choosing "before make" I was hoping to�

How to fix Jfoenix modules with JavaFX 11 and JDK 11, Your browser does not currently recognize any of the video formats __count__/ __total__ Duration: 15:50 Posted: Jul 26, 2019

Comments
  • Thanks for your answer, therefore i have this error now: no main manifest attribute in GymFormManager-1.0-SNAPSHOT-jar-with-dependencies.jar
  • The main manifest attribute refers to your mainClass, do you have a Class-File at <mainClass>com.gymformmanager.Main</mainClass> with a "public static void main(String[] args)" method?
  • Yes i have it ... And when i use exec-maven-plugin it is executed.
  • Sorry, i mixed where you have to put the mainClass... I updated my answer, could you try again with the new plugin config?
  • Thanks a lot to take time for me ! Therefore, i have another error now, i have edited my post ..
  • I already tried it.. look at my pom.xml, it's the same code at yours ..