Mac:如何指定要使用我的java .app应用程序打开的文件扩展名? [英] Mac: How to assign a file extension to be opened with my java .app application?
问题描述
我已经创建了一个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?