Jpackage file assocations OS X
alexander.matveev at oracle.com
alexander.matveev at oracle.com
Wed Sep 23 00:35:07 UTC 2020
Hi Michael,
For file association you will need to create property file and pass it
to jpackage via --file-associations.
Example property file:
mime-type=text/plain
extension=txt
description=Text file
See following documentation:
https://docs.oracle.com/en/java/javase/15/jpackage/support-application-features.html#GUID-8668A806-8A80-435F-970F-7B2BF65863E4
To retrieve associated file(s) when application is invoked by clicking
associated file in Finder use OpenFilesHandler from AWT. See
https://docs.oracle.com/en/java/javase/15/docs/api/java.desktop/java/awt/Desktop.html#setOpenFileHandler(java.awt.desktop.OpenFilesHandler)
Also, for example on how to use above APIs you can refer to test app we
using for jpackage:
https://github.com/openjdk/jdk/blob/master/test/jdk/tools/jpackage/apps/image/Hello.java
We also support CFBundleDocumentTypes from
https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundledocumenttypes?language=objc
just add then to property file mac.key=value with key one of
CFBundleDocumentTypes key and correct value from above doc. Example:
mime-type=text/plain
extension=txt
description=Text file
mac.CFBundleTypeRole=Viewer
mac.LSHandlerRank=Default
mac.NSDocumentClass=SomeClass
mac.LSTypeIsPackage=true
mac.LSSupportsOpeningDocumentsInPlace=false
mac.UISupportsDocumentBrowser=false
mac.NSExportableTypes=public.png, public.jpg
mac.UTTypeConformsTo=public.image, public.data
CFBundleDocumentTypes was added with
https://bugs.openjdk.java.net/browse/JDK-8233215
Thanks,
Alexander
On 9/22/20 12:00 PM, Michael Hall wrote:
>
>> On Sep 22, 2020, at 1:47 PM, Andy Herrick <andy.herrick at oracle.com> wrote:
>>
>> Alexander:
>>
>> Can you explain the mechanism by which a macosx application is expected to retrieve the path to the selected file when the app is invoked via a file association ?
>>
>> On mac, the path to the associated file is not passed as an argument (as it is on Linux and Windows).
>>
>> /Andy
>>
>> On 9/20/2020 8:40 PM, Michael Hall wrote:
>>> Are there any examples or further information on how the file association property file should work?
>>> It is not entirely clear to me from the command help.
>>>
>>>
> Is this currently not intended to be supported on OS X at this time? As I remember you have the extensions and what role they have for the application and things like that. These being entries in the Info.plist. It wasn’t clear to me how that would be applied in a properties file.
>
>
More information about the core-libs-dev
mailing list