How can I package a Java application for Mac so that it can accept any file dropped on it?

Viewed 158

I'm creating a file upload utility in Java, and packaging it as a Mac OS X Application. I'm using Java 17 and jpackage to create my application. Everything is working, except I can't figure out how to use --associate-file with a wildcard so that any file, including directories, can be dropped onto my application. I need this so that my application can upload the file(s) or directories to the cloud.

[UPDATE]

I ended up fixing the problem by parsing the generated Info.plist, removing the jpackage-generated array associated with the CFBundleDocumentTypes, and replacing it with my own array. This seems very kludgey, and I would welcome any answers that explain how to do it using jpackage without post-processing.

The fixed version looks like this:

  <key>CFBundleDocumentTypes</key>
  <array><dict><key>CFBundleTypeExtensions</key><array><string>*</string></array><key>CFBundleTypeRole</key><string>Editor</string></dict></array>

Reference documentation on the CFBundleDocumentTypes can be found at https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-101685-TPXREF107

0 Answers
Related