Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use file associations with jpackage?

I am using jpackage to pack my Java application and want to use it to create file associations. I see that the utility supports this via the --file-associations command. Using this, you can point it to a file that includes file association information.

Does anyone know of documentation that gives a better description of how to create this file-association file? The help documentation in the utility itself describes keys that must appear in it, but there's no hint at how it needs to be formatted.

Here is what the packager lists in its own help:

--file-associations — Path to a Properties file that contains list of key, value pairs (absolute path or relative to the current directory). The keys "extension", "mime-type", "icon", and "description" can be used to describe the association. This option can be used multiple times.

Does anyone here know where I might be able to find an example of this that is written correctly or more detailed documentation on exactly how the feature is used? Would be much appreciated if someone could just point me in the right direction.

like image 915
Draque Thompson Avatar asked Sep 16 '19 04:09

Draque Thompson


Video Answer


1 Answers

You need to write each key-value on each line separated by an equal sign without any quote and save as a text file with .properties extension for example

extension=<Your file extension without leading dot e.g. docx>
mime-type=<Your mimetype e.g. application/msword>
icon=<Path to the icon file e.g. word.ico (Windows) or word.icns (macOS)>
description=<Some description e.g. Microsoft Word Open XML Format Document>

I could not find any official documents either. However, this is how I created my properties file which works on the release version of Java 14.

like image 173
Nuntipat Narkthong Avatar answered Oct 18 '22 19:10

Nuntipat Narkthong