0

I have a Java application which is packaged for Windows via installanywhere, and for OSX via jarbundler into a double-clickable .exe and .app respectively.

I understand associating file types via registry (windows) or plist file (OSX) such that double-clicking a registered file will open my application and the file. This works fine when my application is not running.

My question is about the scenario my application is already running, and I want that instance to receive and handle subsequent double-click events on registered file types, ie, opening more documents in the same instance of the app (like tabs in your browser.)

The current behavior is that the OS starts a new instance of the app and opens the document there - less desirable. Think of my problem as a new instance of photoshop opening each time I double-click a JPG file.

Is there some documentation on how to integrate this for Windows and/or OSX?

  • You may want to rephrase the question a little bit. It's not about receiving double-click events, it's about receiving events for opening registered file types – Cruncher Sep 05 '13 at 16:34
  • Check out http://stackoverflow.com/questions/9321402/associate-file-format-with-my-program-java – higuaro Sep 05 '13 at 16:52

1 Answers1

2
  1. Open a Socket on a certain port; if it fails go to 3
  2. If it connects, send the currently opened file and exit
  3. Open a ServerSocket on the same port and listen for connections (from a subsequent instance of the program)
  4. When a connection is established, receive a file name and open it in another tab
Gabriel Negut
  • 13,860
  • 4
  • 38
  • 45
  • This is brilliant. Though a little bit of extra work to make sure that the socket you connected to was actually your application, and possible an algorithm for which port to check next on fail. – Cruncher Sep 05 '13 at 17:05