Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Clipboard using Toolkit is not working

KSharma04May 6 2016 — edited May 11 2016

Hi ,

I am trying to implement clipboard functionality using the below code

        Toolkit toolkit = Toolkit.getDefaultToolkit();

        Clipboard clipboard = toolkit.getSystemClipboard();

        StringSelection strSel = new StringSelection(strBuild.toString());

        clipboard.setContents(strSel, null);  

It works fine in my local environment but when i deploy the code in testing environment I get the below exception and clipboard does not work

java.awt.HeadlessException at sun.awt.HeadlessToolkit.getSystemClipboard

Please can someone help me how to proceed on this

Thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 8 2016
Added on May 6 2016
6 comments
1,900 views