Launch4J Can't Find Main Class

1.1k views Asked by At

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

There are 0 answers