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>