在OSX上使用捆绑的JRE [英] Using a bundled JRE on OSX

查看:92
本文介绍了在OSX上使用捆绑的JRE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我们的Java应用程序预先捆绑了Windows上的JRE。我们有一个用C编写的小型启动器应用程序,使应用程序使用我们的预捆绑JRE。现在,随着Apple的讨伐慢慢杀死Java,我们已经决定在OSX上做类似的事情是谨慎的。在OSX上使用预捆绑JRE的最佳方法是什么?

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 JRE. Now with Apple's crusade to slowly kill Java we have decided that it would be prudent to something similar on OSX. What would be the best way to use a pre bundled JRE on OSX?

推荐答案

即使我觉得这是一个坏主意(参见下面你可以捆绑一个像OpenJDK这样的JVM,然后用一个小脚本启动你的应用程序,调用你的 java 可执行文件。

Even if I find it a bad idea (see below) you could just bundle a JVM like OpenJDK and then start your application with a small script calling your java executable.

注意:我不知道是否允许重新分发JVM(合法),您应该在下载之前检查协议


  • 您将遇到的第一个问题是目前只有Apple的版本或 Oracle Java 7u6 Mac OS X端口开发人员预览版(这只是一个预览版)。 (例如, http://jdk7.java.net/macportpreview/ )。苹果将​​停止提供自己的版本,这将在未来发生变化。所以目前你只能在Lion上运行预览。但我会给你看一个例子。

  • The first problem you will have is that at the moment there is just Apple's version or Oracle Java 7u6 Mac OS X Port Developer Preview Release (which is just a preview). (e.g., http://jdk7.java.net/macportpreview/). This will change in the future when Apple will stop supplying its own version. So at the moment you are stuck with a preview running on Lion only. But I will show you an example.

下载安装程序,挂载磁盘映像,右键单击插件,选择显示包内容解压主页文件夹,它包含JRE

Download the installer, mount the disk image, right click on the plugin, choose "Show package content" extract the Home folder, it contains the JRE

然后您可以查看

$ ./Home/bin/java
java version "1.7.0_06-ea"
Java(TM) SE Runtime Environment (build 1.7.0_06-ea-b18)
Java HotSpot(TM) 64-Bit Server VM (build 23.2-b08, mixed mode)

然后我会在 jre

如果您将此文件夹打包到您的应用程序中,您只需要包含一个小脚本

If you package this folder with your application you will just have to include a small script with

#!/bin/sh
./jre/bin/java -classpath myniceapplication.jar


  • 为了能够构建一个应用程序,你需要一个包含脚本的 applicationname.app/Contents/MacOS 文件夹(应该命名为的applicationName ) 。

  • To be able to build an application you will need an applicationname.app/Contents/MacOS folder containing you script (which should be named applicationname).

    现在看来你需要在这些剧本中使用绝对路径

    Now it seems that you need the use absolute paths in these scripts

    /Path/applicationname.app/Contents/MacOS/jre/bin/java -classpath myniceapplication.jar
    

    我认为有一个更好的解决方案来构建Mac OS X应用程序包但我不是专家。这个例子只是为了表明它可以工作。

    I suppose that there is a better solution to build a Mac OS X application bundle but I'm not an expert. This example was just to show that it can work.

    总结:


    • 检查是否允许重新分配JRE(并检查哪些条件)

    • Check if it is allowed to redistribute the JRE (and check which are the conditions)

    我不会这样做,因为每次有JRE安全更新时你都必须保持更新并更新你的应用程序

    I would not do it since you will have to keep it updated and update your application every time there is JRE security update

    作为一个用户,我更信任Oracle而不是一个随机的开发人员(没有个人:-)来获得一个JRE

    As a user I would trust more Oracle than a random developer (nothing personal :-) to get a JRE

    这篇关于在OSX上使用捆绑的JRE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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