在Mac OS X的Swing应用程序中嵌入JRE [英] Embedding a JRE in a Swing application for Mac OS X

查看:125
本文介绍了在Mac OS X的Swing应用程序中嵌入JRE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须交付带有嵌入式JRE的swing应用程序.带有应用程序+ JRE + .bat/.sh的压缩归档文件适用于Windows和Linux.用户下载该zip,解压缩,然后启动该应用程序.完美.

I must ship a swing application with an embedded JRE. A zipped archive with application + JRE + .bat/.sh did the trick for Windows and Linux. Users download the zip, unzip it, and launch the application. Perfect.

但是现在,我必须为Mac OS X提供相同的功能.我已经读过/被告知许多不同的事情(禁止在Mac上分发JRE,相反,在Mac上始终有JRE等),所以我对自己能做的事情感到很困惑.

But now, I must provide the same thing for Mac OS X. I have read / was told a lot of different things on that matter (forbidden to distribute a JRE on Mac, the contrary, there is always a JRE on Mac, etc...), so I'm really confused about what I can possibly do.

有人已经做过这样的事情吗?您是如何解决Mac应用程序部署的?作为奖励,在Mac(zip?)中分发我的应用程序的最佳格式是什么?

Does anybody already did such a thing? How did you solved the Mac application deployment? As a bonus, what is the best format to distribute my application in Mac (zip?)?

推荐答案

看看 appbundler java.net上的项目.它提供了一个Ant任务,可以将您的应用程序打包为普通的Mac .app捆绑软件,并且可以选择包括嵌入式JRE.

Have a look at the appbundler project on java.net. It provides an Ant task that will package your application up as a normal Mac .app bundle, and can optionally include an embedded JRE.

由于我们仍处于过渡时期,苹果公司提供和维护Java 6版本,而Java 7版本直接来自Oracle,因此Mac上的整个Java情况目前还有些混乱. a_horse_with_no_name 提及的jarbundler项目用于将JAR打包为.app捆绑软件,该捆绑软件将在Apple-提供了Mac OS X 10.5/6/7附带的Java 6,但不是Oracle Java 7附带的Java 6,相反,打包程序的目标是Oracle Java 7,并且它的.app捆绑软件无法在Java 6上运行.

The whole Java landscape on Mac is a bit of a mess at the moment as we're still in the transitional period where Java 6 releases are supplied and maintained by Apple and Java 7 releases come direct from Oracle. The jarbundler project referred to by a_horse_with_no_name is for wrapping up a JAR as a .app bundle that will run on the Apple-supplied Java 6 that is included with Mac OS X 10.5/6/7, but not on Oracle Java 7, conversely appbundler targets Oracle Java 7 and its .app bundles won't run on Java 6.

如果要针对运行10.7或10.8的最新Mac,尤其是要通过Mac App Store分发应用,则应使用appbundler并捆绑JRE的副本.如果您不想通过商店进行分发,则嵌入式JRE是可选的.如果您的应用程序可以在Java 6上运行,则使用jarbundler定位Apple Java 6将意味着您的应用程序可以在较旧(< = 10.6)的Mac上运行.但是随后,任何拥有更新版本的Mac且仅具有Java 7的Mac都将在尝试运行您的应用时提示他们下载并安装Java 6.

If you want to target recent Macs running 10.7 or 10.8, and in particular if you want to distribute your app via the Mac App Store, then you should use appbundler and bundle a copy of the JRE. If you don't want to distribute via the store then the embedded JRE is optional. If your app can run on Java 6 then targetting Apple Java 6 with jarbundler will mean your app can run on older (<= 10.6) Macs. But then anyone with a more recent Mac that has only Java 7 will be prompted to download and install Java 6 when they try and run your app.

只要将Contents/MacOS目录中的所有内容(以及嵌入式JRE中的相应文件,如果适用)标记为在应用程序中具有执行权限,就可以将.app分发到.zip存档中.压缩文件.如果使用Ant构建,则需要使用<zipfileset>和正确的filemode.

It's fine to distribute the .app in a .zip archive, as long as everything in the Contents/MacOS directory (and the appropriate files in the embedded JRE if applicable) inside the app is marked with execute permission in the zip file. If you're building with Ant you'll need to use <zipfileset>s with the right filemode.

这篇关于在Mac OS X的Swing应用程序中嵌入JRE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆