2

I had spent all day (and many days before) trying to make Launch4J work but for some reason, it can't find the main class file. It will successfully build but running it only causes:

Error: Could not find or load main class net.path.to.Main
Caused by: java.lang.ClassNotFoundException: net.path.to.Main

From research and personal experience, the problem usually relates to not writing out the entire classpath or having and issue with the manifest. I don't think it's a manifest problem because L4J usually directly complains about a manifest. I've checked the manifest and my classpath spelling. It's all correct. What's weird is that if I try to use the same exact jar with JSmooth (last updated in 2007), it works fine.

Seems like Launch4J is the culprit. Would there be any reason this is happening?

Important notes:

  • Writing in Kotlin
  • Computer using Java 1.8.0_202 (mostly to appease Launch4j)
  • Program is using OpenJDK11 in a local bin folder

Current guesses:

  • Java/Kotlin interoperability problems. Rarely happens but I've seen it be an issue before.
  • JavaFX problems. Sometimes launching a JavaFX program can cause errors but there are easy workarounds. I doubt this is the problem, as any errors usually happen after the start of execution; it'd have to find the main class before it could complain.
Steph
  • 831
  • 6
  • 19
  • see https://stackoverflow.com/questions/16945301/javafx2-wrapping-launch4j-as-maven-plugin, maybe it will give you a hint – Михаил Нафталь Oct 09 '20 at 09:10
  • Don't think so, as their problem seems to be in not including resources or with minimum versions. I include all resources in my jar and I'm using a version of OpenJFX. Also, I am having both jsmooth and l4j to use openjdk11 (mentioned in the post). While they don't have any version settings, they are set to only use the bundled jdk and to not use any fallback options. – Steph Oct 09 '20 at 15:13
  • Could you share your launch4j.xml config? – Михаил Нафталь Oct 09 '20 at 15:35
  • Will it complain about main class if you run it not as executable, but as a jar (`java -jar your.exe`)? – Михаил Нафталь Oct 09 '20 at 16:09
  • No, the jar runs fine. – Steph Oct 09 '20 at 16:17
  • I'm having this exact issue and it seems to be size related. When I add a new dependency at around 100 MB (REGARDLESS of which dependency) this starts happening and I'm not seeing much at all about this online – J. Dimeo Aug 26 '23 at 03:46

0 Answers0