问题
I want it like when we do "open with" and then choose Notepad. So that when I "open with" a file there will be my program in the list. How to associate a file type with my program?
How to make the program handle the file?
回答1:
Deploy the app. using Java Web Start.
Java Web Start (JWS) is the Oracle Corporation technology used to launch rich client (Swing, AWT, SWT) desktop applications directly from a network or internet link. It offers 'one click' installation for platforms that support Java.
JWS provides many appealing features including, but not limited to, 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..
This demo. of the file service is deployed using JWS (on OS X, *nix and Windows) and declares an interest in the .zzz
file-type.
回答2:
Best thing would be to create an EXE wrapper for your Java program:
How can I convert my Java program to an .exe file?
and
Best free tool to build an exe from Java code?
are relevant. Then you would need to create a file association. See this KB article on how to do it manually: http://support.microsoft.com/kb/307859
If you use an installer package to package your app you would have to research on how to accomplish this automatically when your program installs.
来源:https://stackoverflow.com/questions/11714904/how-to-make-windows-autoview-a-file-with-my-program-and-how-to-make-the-program