Im trying to create a Java app in Intellij with Maven and jpackage. The .jar file is created correctly and it works and the installer seems to be okay, but when I try to open the app that I got from the installer it opens an error window saying Failed to launch JVM. I created the installer using the Intellij interface and the command: jpackage –input target –name kata7 –main-jar kata7-1.0-SNAPSHOT.jar –main-class org.example.Main –type exe and neither of them works.
This is my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>kata7</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.example.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>jpackage</executable>
<arguments>
<argument>--input</argument>
<argument>./target</argument>
<argument>--name</argument>
<argument>kata7</argument>
<argument>--main-jar</argument>
<argument>${project.name}-${project.version}.jar</argument>
<argument>--main-class</argument>
<argument>org.example.Main</argument>
<argument>--type </argument>
<argument>exe</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
I read in other posts that this could be related to different versions of jdk in my computer but I checked the environment variables, the version im using in the project and the one used to make the build with maven, its version 18 in every one of them. I really dont know what to do to fix this, hope someone can help me.
Raknah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.