Mac 中的文件关联 [英] File association in Mac

查看:31
本文介绍了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 应用程序的 main 方法的参数.我们怎样才能做到这一点.对于我们使用的文件类型关联

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 文件中应该有什么变化吗?

Should there be any change in the Info.plist file?

推荐答案

使用 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屋!

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