dontWrapJar causes 'Could not find or load main class'
Opened this issue · 4 comments
Hi,
great plugin, however I'm having some issues.
I wrap everything into a FAT jar, which I can execute fine.
I would like to create a .exe that executes the jar.
I want to end up with a directory structure of
app
|--app.exe
|--lib
|-- app.jar
so I have created a configuration that looks like:
<configuration>
<headerType>console</headerType>
<outfile>target/app.exe</outfile>
<jar>lib/${project.artifactId}-${project.version}-FAT.jar</jar>
<dontWrapJar>true</dontWrapJar>
<classPath>
<mainClass>${main-class}</mainClass>
<addDependencies>false</addDependencies>
<jarLocation>lib/</jarLocation>
</classPath>
</configuration>
I construct my desired directory structure using the assembly plugin.
The resulting directory structure is correct, however
If I run app.exe
from the directory 'app' that the exe sits in, it works fine,
but if I run it from some other directory it gives the error
Error: Could not find or load main class com.itemis.fit.cli.MainCli
Caused by: java.lang.ClassNotFoundException: ....
How do I ensure that the location is relative to the .exe location, not the directory I run the exe from ?
I have discoved if I set <chdir>.</chdir>
then the exe can find the jar and it works.
Is this the correct thing to do?
I would prefer/expect the pwd to remain as the directory the user runs the exe from!
from top of my head could you try to use <jarLocation>./lib/</jarLocation>
<chdir>
Optional. Change current directory to an arbitrary path relative to the executable. If you omit this property or leave it blank it will have no effect. Setting it to . will change the current dir to the same directory as the executable. .. will change it to the parent directory, and so on.