Copying to global clipboard does not work with Java in Ubuntu

前端 未结 4 1141
悲哀的现实
悲哀的现实 2020-12-08 04:58

The following code from a standalone application works in ubuntu:

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransf         


        
4条回答
  •  温柔的废话
    2020-12-08 05:29

    I got the same problem with the application at my work and here's an article I've found that explain why and possible solutions. I hope it helps.

    Why it happens

    Clipboard persistence is a bug that affects many programs under Ubuntu and other X11-based operating systems. Fixing it is a Google Summer of Code 2010 project. Wikipedia has a good overview of the issue. If you want to fix as a user, you can install Parcellite or another clipboard manager. If you want to fix it as a programmer, you can modify your program to conform to the ClipboardManager specification.

    X-Window wiki

    Using gnome library you could call the store method on the clipboard and fix this. That's the only thing so far that seems to be worth trying. Also saw a similar thing for GTK but only in an Eclipse's bug.

提交回复
热议问题