带有应用程序捆绑器的 Jar 到 Mac OSX 应用程序包 [英] Jar to Mac OSX App Bundle with app bundler

查看:21
本文介绍了带有应用程序捆绑器的 Jar 到 Mac OSX 应用程序包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 app bundler 将我的 .jar 捆绑到 MacOSX 应用程序包.我正在学习本教程.>

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

这是我的 build.xml 文件:

<target name="bundle-RageMage"><delete dir="appBundle" failonerror="false"/><mkdir dir="appBundle"/><bundleapp outputdirectory="bundle"name="狂暴法师"displayname="狂暴法师"图标="res/icon.icns"标识符="ragemage.src.Window"mainclassname="ragemage.src.Window"><classpath file="dist/ragemage_1.1.1.jar"/></bundleapp></目标>

谢谢!

解决方案

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

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

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

<taskdef name="bundleapp"classname="com.oracle.appbundler.AppBundlerTask"classpath="lib/appbundler-1.0.jar"/><!-- 看这里的lib参考,这就是为什么你需要使用lib目录!--><target name="bundle-buttonDemo"><delete dir="appBundle" failonerror="false"/><mkdir dir="appBundle"/><bundleapp outputdirectory="appBundle"名称=按钮演示"displayname="按钮演示"标识符 =components.ButtonDemo"mainclassname="components.ButtonDemo"><!-- 以下内容很重要,应该指向您的构建 --><classpath file="dist/ButtonDemo.jar"/><!-- 如果您是第 3 方或不同位置的依赖 jar --></bundleapp></目标></项目>

  • 构建您的项目
  • 运行 ant 脚本,使用(类似)ant -f {You App Bundler script}

应用程序包,在这种情况下 ButtonDemo.app 将在 appBundle 目录中创建.如果可以,请浏览 ButtonDemo.app/Contents/Java 的内容并确保所有所需的 Jar 文件都在那里...

快乐捆绑!

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

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

2- taskdefname 很重要,您可以在任何脚本中使用它来确定蚂蚁在点击您的标签引用时应该做什么...

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

要么改变这个...

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

<classpath file="dist/ragemage_1.1.1.jar"/></狂暴法师>

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

3- bundleappdeletemkdiroutputdirectory 属性是相关的...

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

或者,将它们全部设为 appBundlebundle,你想要什么...

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

I'm trying to bundle my .jar to a MacOSX app bundle, using app bundler. I'm following this tutorial.

It says to add a lib folder to the high-level project directory, but I don't know what that means. I've been looking everywhere for it, and I cannot find out what it is. That's my only problem I have, anyone know?

EDIT:

Here is my build.xml file:

<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>

Thanks!

解决方案

Okay, so, after having a little play around, this is what I understand...

  • Download Java Application Bundler and place it in the lib directory of your project. You will need to create this directory...
  • Create a new Ant script into your project directory, call it what ever you like...Also, take the time to read through the AppBundler Task Docs

The ant script should be based on the following skeleton...

<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>

  • Build your project
  • Run the ant script, using (something like) ant -f {You App Bundler script}

The app bundle, in this case ButtonDemo.app will be created in appBundle directory. If you can, browse the contents of the ButtonDemo.app/Contents/Java and make sure all your required Jar files are there...

Happy bundling!

Updated based on updated build.xml file

1- There is no default target specified by the project tag. Think of this like your "main class" or "main" method, without, ant has no idea what you want to run...

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

2- The name of the taskdef is significant and you use it in the any script to identify what ant should do when it hits your tag reference...

So based on your example, you either need to change the name of the taskdef from ragemage to bundleapp or change the bundleapp tag to ragemage...

Either change this...

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

or this (in target 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>

Personally, I'd leave it as bundleapp, but that's me...

3- The delete, mkdir and outputdirectory attribute of bundleapp are related...

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

Either, make them all appBundle or bundle, what every you want...

4- You main class is unlikely to be ragemage.src.Window and is probably going to be Window

这篇关于带有应用程序捆绑器的 Jar 到 Mac OSX 应用程序包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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