简体   繁体   English

Mac中的文件关联

[英]File association in 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 . 从这里寻求帮助,我们现在可以从jar文件创建Mac应用程序,并将该应用程序与某些文件扩展名相关联。

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. 但是,我们需要获取选定的文件路径作为java应用程序main方法的参数。 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>

with changes. 随着变化。

Should there be any change in the Info.plist file? Info.plist文件是否应该进行任何更改?

Use Java Web Start to declare the interest in that file-type. 使用Java Web Start声明对该文件类型的兴趣。 Here is a demo of the JNLP file services that associates the .zzz file-type with the app. 这是将.zzz文件类型与应用程序相关联的JNLP文件服务演示 This approach should work for OS X (& Windows, & *nix). 此方法应适用于OS X(&Windows和&* nix)。

Apple provides some specific classes that allow you to better incorporate Java applications into Mac OS X. Google for "Apple Java eawt", or try this link: http://developer.apple.com/library/mac/documentation/Java/Reference/JavaSE6_AppleExtensionsRef/api/com/apple/eawt/package-summary.html . Apple提供了一些特定的类,这些类使您可以更好地将Java应用程序合并到Mac OS X中。对于“ Apple Java eawt”,请使用Google,或尝试以下链接: http : //developer.apple.com/library/mac/documentation/Java/Reference /JavaSE6_AppleExtensionsRef/api/com/apple/eawt/package-summary.html Look especially for the Application- and ApplicationAdapter-Class (reps. their not-deprecated parts). 尤其要查找Application-和ApplicationAdapter-Class(代表它们未使用的部分)。 you can register special listeners to get the information about files that should be opened. 您可以注册特殊的侦听器以获取有关应打开的文件的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM