在Mac文件关联 [英] File association in Mac
问题描述
从这里寻求帮助,我们现在可以创建一个jar文件在Mac应用程序和关联与特定文件扩展名的应用程序。
Finding help from here we are now able create a Mac application from a jar file and associate the application with certain file extension .
当双击与扩展它在该应用程序,并最终在嵌入式Java应用程序中打开一个文件。
When double click a file with that extension it is opening in that application and ultimately in the embedded java application.
但是我们需要的是让所选择的文件路径作为参数传递给Java应用程序的主要方法。
我们怎样才能做到这一点。
对于文件类型关联,我们已经使用
However our need is to get the selected file path as an argument to the main method of the java application. How can we achieve this. for file type association we have used
defaults write com.apple.LaunchServices LSHandlers -array-add
<dict>
<key>LSHandlerContentTag</key>
<string>PUT_FILE_EXTENSION_HERE_WITHOUT_PERIOD</string>
<key>LSHandlerContentTagClass</key>
<string>public.filename-extension</string>
<key>LSHandlerRoleAll</key>
<string>org.category.program</string>
</dict>
有改动。
如果有在 Info.plist中的任何变化
文件?
推荐答案
使用 Java Web Start的来在声明该文件类型的兴趣。下面是JNLP文件服务演示是相关联的 .zzz
文件类型的应用程序。这种方法应该适用于OS X(安培; Windows中,&安培; * nix中)。
Use Java Web Start to declare the interest in that file-type. Here is a demo of the JNLP file services that associates the .zzz
file-type with the app. This approach should work for OS X (& Windows, & *nix).
这篇关于在Mac文件关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!