2

I'm trying to make a program similar to Windows Photo Viewer, the program that pops up usually if you double-click an image in Windows. I've already made my own program, however it uses a JFileChooser associated with a button to bring up images to open inside the application itself (Windows photo app doesn't seem to do this).

Question:

How can I make my application handle certain file types when its double-clicked from Windows? My guess would be something along the lines of my main class having a Path/String type argument of the file I want to open, but I'm not sure how to exactly implement that.

What type does Windows pass to a program whenever we open a file? String?

Once my first question is fixed, is there anything special I would need to do to associate my program to image files (when making .exe file or installer)?

kir
  • 581
  • 1
  • 6
  • 22
  • 1
    Have you tried a [tag:java-web-start] ``, cited [here](http://stackoverflow.com/a/12323471/230513)? – trashgod Sep 19 '13 at 19:36
  • @trashgod: I don't think file associations is my priority atm. I need to be able to take String arguments for my program first. I did check on that already however. It seems I need to be online to run the application (correct me if I'm wrong). I want my program to be able to run just like Windows Photo Viewer, which is just a default offline application integrated to Windows. – kir Sep 19 '13 at 19:50

1 Answers1

3

Include a  <association/> tag as a "hint to the JNLP client that it wishes to be registered with the operating system as the primary handler of certain extensions and a certain mime-type." Note that " the <offline-allowed/> element must also be included." A web server is not required and a platform-specific <shortcut/> is optional. The file to open will be a command line parameter.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045