first: Please be gentle, I'm very new to this.
I have a java application which is a client connecting to a wildfly instance. Running this from IDE works. Now i want to wrap the client to an .EXE using akathist-launch4j-maven-plugin and the maven-shade-plugin. I'm using those instead of jpackage since i dont want an installer, but a plain exe to run the programm. The wrapping works and runs until it tries to call java.util.AbstractMap().
Error message:
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected java.util.AbstractMap() accessible: module java.base does not "opens java.util" to unnamed module @7e32c033
From https://stackoverflow.com/a/41265267/21859971 i gathered it would work if i passed "--add-opens java.base/java.lang=ALL-UNNAMED" to the jvm.
The exclusion filters were added because before it would run into problems with the signed jars inside the shaded one.
The questions now are: a) Is that the right way to go about it?
b) If so, how do I modify the pom to include this argument?
Pom plugins excerpt:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>shaded</shadedClassifierName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>de/cni/client/gui/pages/main/StartApplication</mainClass>
</transformer>
</transformers>
</configuration>
</plugin>
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>l4j-clui</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>console</headerType>
<jar>${project.build.directory}/${project.artifactId}-${project.version}-shaded.jar</jar>
<outfile>${project.build.directory}/app-client.exe</outfile>
<classPath>
<mainClass>[..]/client/gui/pages/main/StartApplication</mainClass>
<preCp>anything</preCp>
</classPath>
<jre>
<path>${java.home}/bin</path>
<minVersion>17.0.2</minVersion>
<maxVersion></maxVersion>
<requiresJdk>true</requiresJdk>
<requires64Bit>true</requires64Bit>
</jre>
</configuration>
</execution>
</executions>
</plugin>
Edit: As is tradition, an hour after posting this i tried something i did before and now it worked. I added:
<opts>
<opt>--add-opens java.base/java.util=ALL-UNNAMED</opt>
<opt>--add-opens java.base/java.util.concurrent=ALL-UNNAMED</opt>
</opts>
to the of the launch4j plugin and now it is running.
I'm not going to put this as an answer since I'm reasonably sure there is a better (correct) way to solve this.