Problems with copy and paste in windows
Apache NetBeans version
Apache NetBeans 13
What happened
This issue has been occurring in this version and earlier. Sometimes when we copy text from a website/browser on Windows operating system, Netbeans pastes information that was copied into Netbeans itself. And many times, I select from the website and drag it to Netbeans, to paste the text.
How to reproduce
The problem is only solved when I restart the application. Note: After presenting the problem, when a blank text is copied inside Netbeans, sometimes, when we copy a text externally, it manages to paste inside Netbeans. If pasted in any Windows environment, the text goes correctly, but within Netbeans, it copies the last information copied into the application.
Did this work correctly in an earlier version?
No
Operating System
Windows
JDK
16.0.2 (64bit)
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
No response
Are you willing to submit a pull request?
Yes
Code of Conduct
Yes
Unfortunately a long standing annoyance, which doesn't seem to have a definitive reproducible cause, or we know whether it's definitely NetBeans or the JDK at fault. Have a read of https://lists.apache.org/thread/xqkwy4wxylmzprxl1wko301hlqz59r7d and some of the flags, logging settings, etc. Be great to get to the bottom of this one!
This is very annoying problem. I teach coding. Usually I code in a Google doc because it is live and students can follow along easily. When I want to compile my code I paste it into NetBeans. It fails and only pastes the last thing I copied from within Netbeans. Apparently the copy and paste works only within Netbeans. THIS IS A PROBLEM. Please fix!
The work around is to open the source file concurrently in a text editor and copy and paste there which updates the source file in Netbeans.
@Montanajim if you have a reliable reproducer, then please share as much information as you can about environment, JDK, Windows version, browser you're pasting from, etc. Does it reproduce immediately, or after a time? Is it after a particular type of content has been added to the clipboard (from anywhere)? Do any of the suggestions in the linked thread above help? Is it NetBeans specific, or can you reproduce with other Java (Swing) applications?
It's well known that this is a problem, just not what the fix should actually be!
I can reproduce the bug through these steps:
- Copy a piece of text in Netbeans
- Paste the text in an applicaiton
- In From this application copy some other text
- Paste the text into netbeans
- Paste it somewhere
- Copy text again
- Every new copy from netbeans from now on will not work anymore. If I do not copy in an outside application the clipboard will now be empty (and not the text from step 6 anymore)
I tested these steps with Notpad++, Firefox and the windows file explorer and have the same result exactly after these steps. Also if I mix applications in between. I checked the logs but no error was reported. I am running Netbeans 13 on Windows 10.0 on amd64 with Oracle JDK 17 (17+35-LTS-2724) but had the same issue on older JDKs.
If I can send you any log files or if I can help somehow please write me.
This happens also in Windows 11 with AdoptOpenJDK 11 and Netbean zip distribution
I have the same Problem. It occurs with any Apache Netbeans version (ranging from NB9 to NB15) and with every JDK Build on Windows that I have tested. This includes Java 8, 11 and 17 via Eclipse Temurin JDK, Azul Zulu JDK and some other JDK builds.
The bug occurs seemingly random.
Edit: Please see @epliskin's workaround as it also works consistently and does not require the extra plug-in from NB 7.1
I have found a workaround that works consistently:
Setup
- Goto
Tools->Plugins(Tab:Settings) - Add the following Mirror:
http://plugins.archive.librebeans.org/catalogue/7.1/catalog.xmland give it a name - Switch to
Available Pluginsand install the PluginCopy and Paste History
(Version 3.2.0 by Michel Graciano) - Restart Netbeans
- Goto
Tools->Options->Miscellaneous->Copy and Paste Historyand check the boxReplace Clipboard Content when pasting from history
Workaround
When the bug occurs, then press Alt+V in NB editor to open the clipboard history and insert any item from the menu that should have been opened by the plugin. Press Ctrl+Z to revert the insertion. The clipboard should work normally now.
Performing the Workaround before the bug occurs does not stop the bug from happening. Only performing the workaround after the bug occurs fixes the problem until the bug occurs again.
Same issue with NB 13 and JDK 17. Doing a Control + c in netbeans and then control + v in netbeans works but control + v in another application doesn't work. In the other application stuff that was copied earlier is pasted (not the stuff that was copied most recently from NB). Reverse doesn't work either.
Doing empty Control+C (i.e. cntrl c without selecting any text) seems to reset this behavior. So, if ctrl v is not pasting the right stuff, do an empty ctrl c in netbeans and then select stuff and cntrl c to copy it. Now do ctrl v on another application to paste. It works.
Once it is pasted, then the problem resurfaces. So you have to do an empty cntrl c again to reset. Crazy.
Same issue with NB12 and NB13 platform applications using JDK 11, 16, 17.
I have the same problem. Windows OpenJdk 16.0.2.
the workaround by @duoduobingbing did not work the Copy and Paste History. The link is dead.
anyone have a workaround too ?
A naive attempt to fix: #4572
Also you may add the following command line option to netbeans.exe (or put it into netbeans.conf):
-J-Dnetbeans.slow.system.clipboard.hack=false
That'd switch off NetBeans Clipboard handling hacks which is enabled by default on all platforms save Mac.
Those hacks were introduced as a workaround for an AWT System clipboard issue around Java 5. They might be obsolete and causing issues now.
Please report back your experience either you are trying a build with the PR or testing the app with the provided flag!
Testing the command line option with Netbeans 14 on Windows 11 and Java 11 The issue persists
Thanks @NicolaIsotta Could you also try with -J-DTopSecurityManager.disable=true.
When you say it persists, is it immediate, or does it happen after some time? If after a time, is there anything you're doing that seems to be a common trigger? Is there anything that seems relevant in View / IDE Log around the time the problem starts occurring?
Are you able to get a log of when it goes south. There discussion of this in
https://lists.apache.org/thread/nsg2pdzrs3go9f4zlhy0gjs2hfxmbdbn
But basically
Edit the netbeans.conf file in netbeans/etc/ to add:
-J-Dorg.netbeans.NbClipboard.level=FINEST
Also check with Java 17. This issue is on how Native Clipboard communicate with the JVM, so the JVM can count as well.
Same issue with NetBeans 15, JDK 17, Windows. Based on duoduobingbing advice above the workaround is simply to open the built-in NetBeans clipboard history dialog with (Ctrl+Shift+D), select an item from history to paste into NetBeans editor and revert insertion with (Ctrl+Z). This magic revitalizes the NetBeans clipboard.
It is so strange that we do not get feedback from the Windows folk running the IDE with -J-DTopSecurityManager.disable=true or -J-Dnetbeans.slow.system.clipboard.hack=false...
-J-DTopSecurityManager.disable=true does not work for me at all, when I am using this option I cannot use the clipoard anywhere outside netbeans. -J-Dnetbeans.slow.system.clipboard.hack=false does work for me, if not combined with -J-DTopSecurityManager.disable=true. Still, I have to recopy text in netbeans to paste it somewhere else.
Besides, using the clipboard history, as mentioned by @epliskin , also works for me. (I am using Netbeans 14 on Oracle JDK 17)
An hour ago I configured netbeans.conf with (-J-DTopSecurityManager.disable=true -J-Dorg.netbeans.NbClipboard.level=FINEST) and started NetBeans 15 with JDK 17. Clipboard works as yet fine between NetBeans and other Windows programs. At this time I do not edit any code eagerly but will report here in coming days or weeks if and when NetBeans clipboard freezes again...
I wanted to thoroughly test before writing that this and that option definetely works or does not work; but here are my results after running with some options for a longer time:
-J-Dnetbeans.slow.system.clipboard.hack=false: The bug seemed to occur less frequently but it still occured.-J-Dnetbeans.slow.system.clipboard.hack=falseand-J-Dorg.netbeans.NbClipboard.level=FINEST: Seems to fix the issue. The bug did not occur once during using these.-J-Dorg.netbeans.NbClipboard.level=FINEST: Seems to suffice. Have not used it as long as the others (less than one month) but the bug did not occur. Hopefully this is not tied to a race condition whereorg.netbeans.NbClipboard.level=FINESTfixes it for most people but not all.-J-DTopSecurityManager.disable=true: Did not change anything. The bug still occured.-J-DTopSecurityManager.disable=trueand-J-Dorg.netbeans.NbClipboard.level=FINEST: The bug did not occur.
See attached NetBeans log for this bug. I was editing some code when it happened. Could not paste from other Windows app, could not copy from NetBeans to another Windows app, but still could copy and paste text inside NetBeans editor.
netbeans_default_options = ... -J-DTopSecurityManager.disable=true -J-Dorg.netbeans.NbClipboard.level=FINEST
I have the same problem with Netbeans 16, JDK 18. I have experienced the problem only in Java files so far, when I copy a text from pom.xml, for example, it works fine. Adding -J-Dorg.netbeans.NbClipboard.level=FINEST to netbeans.conf seems to fix the problem.
I have the same problem with Netbeans 16, JDK 18. I have experienced the problem only in Java files so far, when I copy a text from
pom.xml, for example, it works fine. Adding-J-Dorg.netbeans.NbClipboard.level=FINESTtonetbeans.confseems to fix the problem.
Yes. i confirm. it works.
Adding -J-Dorg.netbeans.NbClipboard.level=FINEST isn't a fix, and judging from @epliskin comments doesn't always mask the issue either. Enabling all the additional logging might be helping with a race condition, or maybe eagerly acquiring the transfer data in logFlavors() is helping - https://github.com/apache/netbeans/blob/master/platform/o.n.bootstrap/src/org/netbeans/NbClipboard.java#L288
ha i've seen this problem since i started using netbeans v5. Still happens today. Seems more frequent of an issue with nb17 that in previous versions
Same issue with NB14, NB15, NB16, NB17 platform applications using JDK 11, 16, 17. This is very annoying. The most disturbing part is that all of our Netbeans Platform applications are affected.
Please address this issue. Most of the "hacks" do sometimes work but not always.
Please address this issue. Most of the "hacks" do sometimes work but not always.
Then please help figure out what the cause of the issue is. If this issue was consistently reproducible or we knew what was causing it, it'd be fixed already!
-J-Dnetbeans.slow.system.clipboard.hack=false seems to work for me. NB 17 and JDK 17.
Where can this issue be upvoted? Because it is very annoying. A core functionality not working properly.
@cquoss just try some of the suggestions above and report back if anything helps! Upvoting is pointless - we know it's an issue - we need to be able to replicate the problem, or know what is a reliable workaround, in order to be able to fix it.