Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dontWrapJar causes 'Could not find or load main class' #388

Open
dhakehurst opened this issue Jul 22, 2024 · 4 comments
Open

dontWrapJar causes 'Could not find or load main class' #388

dhakehurst opened this issue Jul 22, 2024 · 4 comments

Comments

@dhakehurst
Copy link

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 ?

@dhakehurst
Copy link
Author

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!

@akuhtz
Copy link
Contributor

akuhtz commented Jul 22, 2024 via email

@lukaszlenart
Copy link
Collaborator

from top of my head could you try to use <jarLocation>./lib/</jarLocation>

@lukaszlenart
Copy link
Collaborator

<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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants