Search code examples
macosjavafxfile-associationinfo-plist

Associate file extension with JavaFX Mac OS X application


I have bundled a JavaFX application for Mac OS X. I am now trying to associate a file extension with the sample.app application. This is the last question I can find about this matter but I can't get it to work. Is there something new that I am missing?


Solution

  • The ability to specify file associations for OS X native packaged applications was a new feature added to the Java client packager in Java 8u40.

    From the Oracle Java 8u40 client application deployment documentation:

    7.3.7 Associating Files with a Self-Contained Application

    The installer for a self-contained application can be set up to register file associations for the application. The element is used in an Ant task to identify the files that can be handled by the application. File associations are based on either the file extension or MIME type.

    The following example associates the application with files that have the MIME type application/x-vnd.MyAppFile.

    <fx:info title="Association example">   
        <fx:association
            mimetype="application/x-vnd.MyAppFile" description="Sample Test Files">   
        </fx:association> 
    </fx:info>
    

    Relevant issues which were implemented for Java 8u40: