Java - Clipboard copied content disappear after program exits
<p>I would like to replace the system clipboard content with my java code, 
but the copied content disappears once the java program exits. How can I make the data persistent?</p>

<p>Thanks a lot.</p>

<pre><code>        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable t = clipboard.getContents(null);

        if (t.isDataFlavorSupported(DataFlavor.stringFlavor))
        {
            String data = (String) t.getTransferData(DataFlavor.stringFlavor);
            System.out.println(data);
        }

        StringSelection stringSelection = new StringSelection("Replaced Text");
        clipboard.setContents(stringSelection, null);

        // just to keep program running... 
        Scanner scanner = new Scanner(System.in);
        scanner.nextLine();
</code></pre>

<p>edit: I work on Ubuntu 10.10, with java version 1.6_20.</p>
