我如何从我的Java .jar文件创建可执行的Apple .app文件? [英] How can i create executable apple .app file from my java .jar file?

查看:164
本文介绍了我如何从我的Java .jar文件创建可执行的Apple .app文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个可执行的Java Swing .jar应用程序.在Windows上可以正常使用.应用程序层次结构是:

I have created an executable java Swing .jar application. It works fine on Windows. The application hierarchy is :

application.jar

application.jar

images(Folder)..........包含应用程序使用的所有图像.

images(Folder) .......... Contains all images the application uses.

libraries(Folder).......包含应用程序使用的所有外部jar库.

libraries(Folder) ....... Contains all external jar libraries the application uses.

bundles(Folder).........包含应用程序使用的所有捆绑文件.

bundles(Folder) ......... Contains all bundle files the application uses.

database(Folder)........包含应用程序使用的数据库文件.

database(Folder) ........ Contains the database files the application uses.

以上所有文件夹都位于jar文件外部.现在,我试图从"application.jar"创建Mac可执行文件(.app).在Mac上运行它,所以我使用了"Jar Bundler"如此处所示,但是当我运行输出application.app文件时,没有任何反应,没有任何反应,并且我什至无法调试它.

All the above folders exist outside the jar file. Now i am trying to create a Mac executable file (.app) from "application.jar" to run it on Mac so i used the "Jar Bundler" as specified here but when i run the output application.app file nothing happens, nothing runs and i can't even debug it.

我认为主要原因是看不到外部文件夹.因此,如果应用程序具有外部文件夹,则不可能创建.app文件吗? 有没有一种方法可以调试.app文件以查看发生了什么事?

I think the main reason is that it can't see the external folders. So is it impossible to create a .app file if the application has external folders ? And is there a way to debug the .app file to see what's going on ?

推荐答案

问题很可能出在您的工作目录中.

Most likely the problem is your working directory.

  • 通过双击运行可执行JAR文件时,工作目录是JAR文件的父目录.

  • When you run an executable JAR file by double-clicking it, the working directory is the parent directory of the JAR file.

默认情况下,应用程序捆绑包的工作目录是其父目录.如果将外部文件夹打包到应用程序捆绑包中,它们将位于$APP_PACKAGE/Contents/Resources下.

By default, the working directory of an application bundle is its parent directory. If you package the external folders into the application bundle they will be located under $APP_PACKAGE/Contents/Resources.

因此,关于您为可执行JAR文件创建的工作目录的假设不适用于应用程序捆绑包.

So the assumption about the working directory that you make for an executable JAR file does not hold for an application bundle.

为了将工作目录设置为资源目录,请添加

In order to set the working directory to the resources directory, add

<key>WorkingDirectory</key>
<string>$APP_PACKAGE/Contents/Resources</string>

到捆绑软件的Info.plist文件.

如果您对应用程序捆绑包一无所知,请阅读

In case you know nothing about application bundles, please read this document.

这篇关于我如何从我的Java .jar文件创建可执行的Apple .app文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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