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?
Asked
Active
Viewed 672 times
1 Answers
1
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:

jewelsea
- 150,031
- 14
- 366
- 406
-
1Great! I was actually reading the documentation while you were answering this question. Although I still have a problem: the OpenFilesEvent only fires if my application is already running and I double click on a file with the handled extension. Is it possible to fire this event also if it is the double-click itself that opens the application? – u09 Mar 24 '15 at 21:42
-
What is the `OpenFilesEvent`? Can you link to where it is documented? OK, I think I see from the link in your question `com.apple.eawt.AppEvent.OpenFilesEvent`. I don't think `com.apple` APIs are supported in the Oracle Java Runtime even if they might sometime work (I don't know that for sure). – jewelsea Mar 24 '15 at 21:47
-
I am using the setOpenFilesHandler in order to know which file opened my application [here is the documentation](http://www.coderanch.com/how-to/javadoc/appledoc/api/com/apple/eawt/Application.html#setOpenFileHandler%28com.apple.eawt.OpenFilesHandler%29). I am doing this so that when i double-click on a file I can open my application and display the file content. The problem is that the OpenFilesEvent fires only if my application is already opened. – u09 Mar 24 '15 at 21:57
-
Yes, but that is documentation for the Apple version of Java, the last version of which (as far as I know), was Java 1.6. It is not documentation for the Oracle version of Java for the Mac (which is what you are using and to which my answer relates). It is unlikely that the documentation and functionality you link applies to and is officially supported by the Oracle Java runtime for Mac. – jewelsea Mar 24 '15 at 22:00
-
I advise that you post a link to your previous related (and currently unanswered) StackOverflow question: [Pass Parameters to JavaFx Application by double-click on file](http://stackoverflow.com/questions/29101472/pass-parameters-to-javafx-application-by-double-click-on-file) on the [JavaFX developer mailing list](http://mail.openjdk.java.net/mailman/listinfo/openjfx-dev) and see if somebody there has the expertise to answer it (I do not have such expertise). – jewelsea Mar 24 '15 at 22:03