5

Here's how I created a jar file using maven.

Now for my JavaFX Application, I'm using afterburner FX Framework. Now I need to create an installer for this app to be deployed to other devices. I'm using Install4j. My steps:

  1. mvn clean package
  2. copy and paste the generated jar file into a different directory
  3. add that directory to install4j Files
  4. on Launcher under Java invocation, I select the jar file, and then I select my main class: `BOOT-INF.classes.inc.pabacus.TaskMetrics.TaskMetricsApplication`
  5. I Build the installer and run it, install to Program files, and then open the exe file

But then an error dialog shows up:

java.lang.NoClassDefFoundError: BOOT-INF/classes/inc/pabacus/TaskMetrics/TaskMetricsApplication (wrong name: inc/pabacus/TaskMetrics/TaskMetricsApplication)

Rigo Sarmiento
  • 434
  • 5
  • 21

2 Answers2

2

So what I did wrong was two things:

  1. Initially, like way way back, I tried using JavaFX with Spring Framework - unsuccessfully. I'm no longer using Spring, but I still had some leftover Spring in my pom file, which caused it to put the files in a BOOT-INF directory when i package it to jar. I just simply had to remove the Spring leftovers, and the boot-inf directory was gone.

  2. So in install4j, you select a directory that would contain the files you would add to your installer. In the tutorials, they had a separate lib directory which contained external libraries. So I thought that's all I needed. I copied my dependencies into a lib folder via maven, then i put them into a directory along with my jar. So that's all my directory had - the jar file and the lib folder. That doesn't work. I didn't know. Apparently, it needs all the files inside the target folder generated by maven. I should've just used the target folder itself.

So there you have it. I have now successfully created an installer. I do hope no one walks as silly as me, but if you had also encountered the same mess up, well... here ya go.

Rigo Sarmiento
  • 434
  • 5
  • 21
  • 2
    This is my first time starting a bounty, so I'm just commenting this just in case. I started the bounty before I found the answer myself. – Rigo Sarmiento Sep 13 '19 at 06:00
1

You seem to have configured

BOOT-INF.classes.inc.pabacus.TaskMetrics

as the main class when the correct package name is

inc.pabacus.TaskMetrics.TaskMetricsApplication

Alternatively, your VM parameters configuration for the launcher is incorrect and includes text that can be interpreted main class.

Ingo Kegel
  • 46,523
  • 10
  • 71
  • 102
  • Well in the install4j wizard, I was asked to select from a list of main classes. `BOOT-INF.classes.inc.pabacus.TaskMetrics` was all I had. I couldn't find any `inc.pabacus.TaskMetrics.TaskMetricsApplication`. Though I'll try later if It'll work when I just type that out. – Rigo Sarmiento Sep 12 '19 at 05:42
  • `your VM parameters configuration for the launcher is incorrect and includes text that can be interpreted main class.` I actually didn't add any VM parameter configurations during the install4j run. – Rigo Sarmiento Sep 12 '19 at 05:44
  • Then you have configured the class path incorrectly, if it's a directory with class files, you have to select the directory with the root package, that's the parent directory of "inc". – Ingo Kegel Sep 12 '19 at 09:09
  • `you have to select the directory with the root package` Sorry I don't quite follow. I selected whatever option showed up in the Java invocation part of the Launcher section of install4j – Rigo Sarmiento Sep 13 '19 at 03:48
  • You can add any directory to the class path, you have to choose the correct one in terms of the class path. – Ingo Kegel Sep 13 '19 at 05:37