We've developed a JavaFX app that we're planning on submitting to the Mac App Store but discovered quite late in the day that in its current form — because it has functionality/usage limits connected to a subscription paid for on our website — it'll likely be rejected for offering those additional features via a mechanism other than In App Purchase (Review Guidelines sections 7.1, 7.13 and 7.15).
We'd like to solve this by adding In App Purchases to our JavaFX app!
The first solution I thought of would be to include a "helper app" inside the .app bundle containing the JavaFX classes, bundled JRE and native wrapper generated by javapackager
. That helper app would be invoked from the JavaFX app and would present a list of In App Purchases. Great! Except that IAPs are accessible using StoreKit only from the application bundle to which they are associated on iTunes Connect. And helper apps inside my .app bundle cannot share the same bundle ID as the main application (the native wrapper).
Another solution would be if I could replace the simple native wrapper generated by javapackager
with my own executable. When the .app was launched, my own native wrapper would invoke the JAR using the bundled JRE just like the current wrapper does, but it could also present a UI for making In App Purchases (communication between the Java part and its wrapper would probably be difficult but ultimately it could be achieved via something as stupid as one part writing to a [sandboxed] file that the other monitored).
My question then is: is the source code for the native wrapper/launcher generated by javapackager
– or the source code for javapackager
itself – available anywhere? And if not, does anyone know how the JAR file bundled in the .app under /Java
is invoked by that launcher?
Yes you can.
The source code for the JavaFX launcher is freely available at the OpenJDK website. To get started you'll want to copy the main.m
file from the main/native/launcher/mac
folder in the source repository. For Java FX 8, that's here: http://hg.openjdk.java.net/openjfx/8/master/rt/file/f89b7dc932af/modules/fxpackager/src/main/native/launcher/mac/main.m.
You then create a new project in Xcode and copy in that main.m file. When you build the project a .app bundle is generated and under the Contents/Mac OS
folder in that bundle is your new launcher executable. Copy that into the app bundle generated by javapackager
and run that bundle as normal, and it'll be your custom launcher that's executed first.