Mac:如何指定要使用我的java .app应用程序打开的文件扩展名? [英] Mac: How to assign a file extension to be opened with my java .app application?

查看:322
本文介绍了Mac:如何指定要使用我的java .app应用程序打开的文件扩展名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个Java应用程序,并从中创建了一个Mac .app文件,可以在Mac OS X上简单运行.该应用程序可以创建特殊的项目文件,并以* .ksdi扩展名保存,因此用户可以轻松地运行这些项目再次编辑文件.

I have created a Java application and created a Mac .app file from it to run simply on Mac OS X. The application can create special project files and save them with the extension *.ksdi so the user can easily run those project files again and edit them.

我想做的是允许在Mac上安装了该应用程序的用户能够双击那些* .ksdi文件来自动运行程序并自动加载项目文件.如何在Mac中做到这一点?

What I would like to do is allow the user who installed the application on his Mac to be able to double click those *.ksdi files to automatically run the program and automatically load the project file. How can I do that in Mac?

我可以通过脚本或类似的方式将扩展名分配给Mac程序,这样用户就不必手动将扩展名分配给该程序了吗?

Can I assign an extension to my Mac program through a script or something like that so user won't have to assign the extension to the program manually?

更新:试用解决方案:

我在另一篇文章中读到,我应该在* .plist文件中添加一个密钥来完成此操作,因此我将其添加到了其中:

I have read in another post that I should add a key to the *.plist file to accomplish this, so I added this to it:

<plist>
    <dict>
        <key>CFBundleDocumentTypes</key>
        <array>
            <dict>
                <key>CFBundleTypeRole</key>
                <string>Viewer</string>

                <key>LSIsAppleDefaultForType</key>
                <true/>

                <key>LSItemContentTypes</key>
                <array>
                    <string>public.ksdi</string>
                </array>
            </dict>
        </array>
    </dict>
</plist>

我保存了plist文件,但是我不知道如何激活它! 我已经运行了该应用程序,重新启动了Mac,但是仍然双击任何ksdi文件都无法使用该程序打开它.有什么帮助吗?

I saved the plist file, but I do not know how to activate this! I have run the application, restarted my mac, but still when double clicking any ksdi file it doesn't open it with the program... Any help?

推荐答案

按照"

用户系统上所有可用的应用程序都必须注册到 使他们知道启动服务并复制其文档绑定,以及 其他信息进入其数据库.通常没有必要 明确执行此任务,因为各种实用程序和 Mac OS X系统软件中内置的服务可以解决该问题 自动:

All applications available on the user’s system must be registered to make them known to Launch Services and copy their document binding and other information into its database. It isn’t ordinarily necessary to perform this task explicitly, since a variety of utilities and services built into the Mac OS X system software take care of it automatically:

内置的后台工具,在系统启动或新安装时运行 用户登录后,会自动在 系统,网络,本地和用户域,并注册任何新域 它在那里找到的应用程序. (此操作类似于 在Mac OS的早期版本中重建桌面".)Finder 意识到所有应用程序后会自动注册, 例如当它们被拖到用户的磁盘上或当用户 导航到包含它们的文件夹.当用户尝试打开时 无法在其中找到首选应用程序的文档 启动服务数据库,Finder出现一个对话框,询问用户 选择用于打开文档的应用程序.然后 在启动之前注册该应用程序.

A built-in background tool, run whenever the system is booted or a new user logs in, automatically searches the Applications folders in the system, network, local, and user domains and registers any new applications it finds there. (This operation is analogous to "rebuilding the desktop" in earlier versions of Mac OS.) The Finder automatically registers all applications as it becomes aware of them, such as when they are dragged onto the user’s disk or when the user navigates to a folder containing them. When the user attempts to open a document for which no preferred application can be found in the Launch Services database, the Finder presents a dialog asking the user to select an application with which to open the document. It then registers that application before launching it.

尽管有这些自动注册实用程序,有时 向Launch显式注册应用程序是必要的 服务.例如,尽管鼓励开发人员打包 他们的应用程序,以便只需拖动即可安装它们 它们放在用户磁盘上,某些应用程序可能需要更多 精心定制的安装程序软件.在这种情况下,安装程序 应该调用启动服务注册功能之一 LSRegisterFSRef或LSRegisterURL注册应用程序

In spite of these automatic registration utilities, it may sometimes be necessary to register an application explicitly with Launch Services. For example, although developers are encouraged to package their applications so that they can be installed by simply dragging them onto the user’s disk, some applications may require more elaborate custom installer software. In such cases, the installer should call one of the Launch Services registration functions LSRegisterFSRef or LSRegisterURL to register the application explicitly.

这篇关于Mac:如何指定要使用我的java .app应用程序打开的文件扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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