3

We have 2 java applications running on MAC. One background application sends either a text or image to a clipboard, then the other application grabs that data and paste it in its application.

We have this problem when the app copies something on the clipboard, the background app won't be able to update the clipboard until it's UI becomes active.

Is there work around with this clipboard issue? This works on Windows and Linux, it seems to be a problem only on MAC.

  • 2
    Is it necessary to use the clipboard as your data transfer mechanism? What about RMI on localhost? – Jesse Barnum Jan 27 '11 at 23:49
  • +1 to finding another way to get the data from one app to the other - it's generally frowned upon for an app to update the clipboard (potentially overwriting the previous contents) without an explicit user action – Martin McNulty Mar 14 '11 at 01:18

1 Answers1

0

Don't.

What you are doing is generally referred to as "interprocess communication". There are various strategies to accomplish this. One of the more 'correct' approaches, in your cotext of two Java applications, would be to use Java RMI.

Doing it in a non-standard, "hackish" manner like you are with the clipboard is more problematic...as you have discovered the hard way.

Even if you did manage to get it running, the possibilities of problems in the future are high. E.g.: Imagine a Windows update changing the behavior of the clipboard--it would break your app on Windows.

Community
  • 1
  • 1
Stu Thompson
  • 38,370
  • 19
  • 110
  • 156