问题
I want to be able to double click on textfile.myext and have my java program open and handle the file.
How should I go about making my program accept files that are set as default to open in said program?
What are the steps and what is passed to the program after something is set as default?
回答1:
Deploy the app. using Java Web Start, which provides..
..splash screens, desktop integration, file associations, automatic update (including lazy downloads and programmatic control of updates), partitioning of natives & other resource downloads by platform, architecture or Java version, configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.), easy management of common resources using extensions..
To see how it is done, visit the demo. of the file services, the filetest.zip
contains the source, launch file and build file. The demo. ..
..prompts the user to associate file extension
.zzz
(simply a file type unlikely to clash with existing file associations) of content typetext/sleepytime
.
If the user asks to open a file, the arguments will be -open path/to/file.name
or for print it will be -print path/to/file.name
.
JWS is supplied with the JRE, and works on OS X, Windows & *nix.
来源:https://stackoverflow.com/questions/9659543/how-to-associate-a-file-type-with-a-my-java-application-on-osx