Copy To Clipboard Doesn’t work in Java

Writing by on Friday, 30 of May , 2008 at 10:59 am

We recently migrated from Java 4 to Java 6 and found out that Copy To Clipboard from JTable, JTextBox etc. just didn’t work.

String selection = “Clip This”;
StringSelection data = new StringSelection(selection);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(data, data);

Then I happened to notice that there was an exception on startup and it couldn’t find


It occurred to me at that point that the there was a SPACE in the location “Program Files” and God Knows why thats not handled correctly. So I simply uninstalled Java 6 from its Default Location and reinstalled it in C:\jdk1.6.0_6 and that did it for me.

Change Default Install Location
I did a lot of searching for solutions, but looks like nobody else ran into this problem. Hey, fixing these type of issues is what we developers get paid for, right? But Microsoft, Sun – PLEASE – Don’t point fingers at each other. Just handle these issues.

Leave a comment

Category: Java

No Comments

No comments yet.

Leave a comment

You must be logged in to post a comment.

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.