Using a bundled JRE on OSX

后端 未结 5 683
面向向阳花
面向向阳花 2020-12-28 17:55

For some time now, our Java application has came pre bundled with a JRE on Windows. We have a little launcher app written in C that make the application use our pre bundled

5条回答
  •  一向
    一向 (楼主)
    2020-12-28 18:37

    I'm the author of the blog post linked by @Daniel in his answer. I successfully bundled the OpenJDK and published a Java app on the Mac App Store.

    First, let me correct some issues in the accepted answer.

    • It is perfectly legal to bundle the OpenJDK and to redistribute it.
    • The OpenJDK doesn't run only on Lion, I used it on pre-Lion up to Mountain Lion. It needs to be patched to work on a 32 bit OS though.
    • The OpenJDK is in beta quality but it's still acceptable to run a complex Swing application. There are a few issues on OSX, but I described how to fix them in this post.

    There's no need to create any script as described in @Matteo's answer, you can use an application called AppBundler, published by Oracle, to create the native executable that will launch your application and create a native bundle. AppBundler will also generate a Info.plist file that contains info on how to launch your application, like the name of the executable to launch, Java arguments etc...

    From 10.7.5 and above your app has to be Gatekeeper compatible and signed (so you must enroll in the paid Mac developer program) if you don't want a dialog saying that your app is from an unidentified developer to appear when the user first opens it.

    To be deployed on the App Store your app also has to be able to work in a sandboxed environment but it's not a strict requirement if you distribute it outside the App Store.

    Note that AppBundler lack some useful features, you may be interested in this fork.

提交回复
热议问题