【问题标题】:Jar to Mac OSX App Bundle with app bundlerJar to Mac OSX App Bundle with app bundler
【发布时间】:2014-07-27 05:31:42
【问题描述】:

我正在尝试使用 app bundler 将我的 .jar 捆绑到 MacOSX 应用程序包。 I'm following this tutorial.

它说要在高级项目目录中添加一个lib 文件夹,但我不知道这是什么意思。我一直在到处寻找它,但我找不到它是什么。这是我唯一的问题,有人知道吗?

编辑:

这是我的build.xml 文件:

<project name="Rage Mage" basedir=".">
<taskdef name="ragemage"
         classname="com.oracle.appbundler.AppBundlerTask"   
         classpath="lib/appbundler-1.0.jar" />

<target name="bundle-RageMage">
    <delete dir="appBundle" failonerror="false"/>
    <mkdir dir="appBundle"/>
    <bundleapp outputdirectory="bundle"
        name="Rage Mage"
        displayname="Rage Mage"
        icon="res/icon.icns"
        identifier="ragemage.src.Window"
        mainclassname="ragemage.src.Window">
        <classpath file="dist/ragemage_1.1.1.jar" />
    </bundleapp>
</target>

谢谢!

【问题讨论】:

  • 我想,in 目录是您所有依赖的 jars/库。本教程以使用NetBeans为基础,它的主jar存放在dist目录下,所有依赖的jar存放在dist/lib目录下
  • @MadProgrammer 没有看到它是针对 NetBeans 的。你知道 Eclipse 的任何替代品吗?
  • 基本上是相同的过程,您需要将所有相关的 Jars 复制到“高级项目”中,无论 Eclipse 采用何种结构......
  • @MadProgrammer 我一直在寻找如何制作 MacOSX 应用程序包已经很久了,但这个应用程序捆绑工具仍然不适合我。我已经尝试了很多东西,但我不知道该怎么做。您知道以前用过的简单方法吗?
  • 我认为教程相当简单,我自己还没有真正尝试过,尝试过阅读AppBundler Task Doc?

标签: java macos bundle


【解决方案1】:

好的,所以,玩了一会儿,这就是我的理解......

  • 下载Java Application Bundler并将其放在项目的lib目录中。您将需要创建此目录...
  • 在您的项目目录中创建一个新的 Ant 脚本,您可以随意命名它...另外,请花时间阅读AppBundler Task Docs

ant脚本应该基于以下骨架...

<project name="ButtonDemo" default="bundle-buttonDemo" basedir=".">        
    <taskdef name="bundleapp"
             classname="com.oracle.appbundler.AppBundlerTask"   
             classpath="lib/appbundler-1.0.jar" />
    <!-- See the lib reference here, this is why you need to use the lib directory! -->

    <target name="bundle-buttonDemo">
        <delete dir="appBundle" failonerror="false"/>
        <mkdir dir="appBundle"/>
        <bundleapp outputdirectory="appBundle"
            name="ButtonDemo"
            displayname="Button Demo"
            identifier="components.ButtonDemo"
            mainclassname="components.ButtonDemo">
            <!-- The following is important and should point to your build -->
            <classpath file="dist/ButtonDemo.jar" />
            <!-- You can have multiple instance of classpath if you 3rd party or
                 dependent jars in different locations -->
        </bundleapp>
    </target>
</project>
  • 构建您的项目
  • 运行 ant 脚本,使用(类似于)ant -f {You App Bundler script}

应用程序包,在本例中为 ButtonDemo.app,将在 appBundle 目录中创建。如果可以,请浏览ButtonDemo.app/Contents/Java 的内容并确保您需要的所有 Jar 文件都在那里...

打包愉快!

根据更新的 build.xml 文件更新

1- project 标签没有指定 default 目标。把它想象成你的“主类”或“主”方法,没有,蚂蚁不知道你想运行什么......

<project name="Rage Mage" basedir="." default="bundle-RageMage">

2- taskdef 中的 name 很重要,您可以在任何脚本中使用它来确定 ant 在遇到您的标签引用时应该做什么...

因此,根据您的示例,您要么需要将 taskdef 的名称从 ragemage 更改为 bundleapp,要么将 bundleapp 标签更改为 ragemage...

要么改变这个......

<taskdef name="bundleapp"
     classname="com.oracle.appbundler.AppBundlerTask"   
     classpath="lib/appbundler-1.0.jar" />

或者这个(在目标bundle-RageMage)

<ragemage outputdirectory="bundle"
    name="Rage Mage"
    displayname="Rage Mage"
    icon="res/icon.icns"
    identifier="ragemage.src.Window"
    mainclassname="ragemage.src.Window">
    <classpath file="dist/ragemage_1.1.1.jar" />
</ragemage>

就我个人而言,我会将其保留为 bundleapp,但这就是我...

3- bundleapp 的 delete、mkdir 和 outputdirectory 属性相关...

<delete dir="appBundle" failonerror="false"/>
<mkdir dir="appBundle"/>
<bundleapp outputdirectory="bundle"...

要么,把它们全部变成appBundle 或bundle,你想要什么......

4- 你的主类不太可能是ragemage.src.Window,很可能是Window

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2014-08-01
  • 2012-09-12
  • 1970-01-01
  • 1970-01-01
  • 2020-04-22
  • 1970-01-01
  • 2022-12-27
  • 1970-01-01
相关资源
最近更新 更多