简体   繁体   中英

jpackage MacOS launcher works on sw mfg. iMac, but can't find main() on installed computer

This is an educational Java/Swing app (JDK 16.0.2) which I'm trying to manufacture for MacOS distribution.

I'm using jpackage (jdk-16) to build the installer/launcher. Learning the Terminal/Xcode command line interface has been....interesting.

When I test the installer on the sw mfg. host intel-iMac, it launches correctly, including showing the app's splashscreen and icon set.

But, when I run the same installer on a different intel-iMac then launch, the launcher can't find the main class: (bug replicated on a MacBook Pro)

Excerpt from launcher TerminalExec session:

Error: Could not find or load main class workspace2D.DataflowGeometry2D Caused by: java.lang.ClassNotFoundException: workspace2D.DataflowGeometry2D

What could cause the launcher to fail to find main() except on the mfg. host iMac?

The installed.cfg file has:

app.mainclass=workspace2D/DataflowGeometry2D

which is the correct reference satisfying the launcher in the first test case.

I finally figured this out. The "jpackage" documentation is weak as far as the necessary preconditions in your file structure for your Java project. All the examples they show are "toy" projects ("HelloWorld") thus avoiding how a typical app-project as structured.

My mistake was creating my MacOS_Manufacturing folder (a target location for the.jar and for the installer.dmg) OUTSIDE the Project folder.

The --input parameter to jpackage names a folder on the sw mfg. computer whose entire contents will be copied onto the installed computer --> MyApp.app/Contents/app folder. I was naming the Project/bin folder as the "--input", which was copying all the.class files and datafiles -- but NOT the.jar. What threw me off is that my DataflowGeometry2D.class files was sitting right there on the installed computer, and yet the launcher couldn't find it???

The launcher is looking for main-class INSIDE the jar, not as a standalone.class file.

I moved the target location for the.jar on the sw mfg. computer to be inside the Project/bin folder. That guarantees it is copied onto the installed computer during the install.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM