解决NetBeans 22无法正常拷贝

NetBeans 22会出现无法使用Ctrl+C或者菜单选项来进行代码拷贝的情况。例如:从NetBeans 22中拷贝一段代码至Visual Studio 2022中,则有时候可以拷贝,有时候则怎么也拷贝不过去。在NetBeans 22中多次点击Copy菜单项,也无法将代码拷贝至剪贴板之中。

修正此问题的方法是通过调整NetBeans的netbeans.conf文件来实现。在netbeans.conf文件中的netbeans_default_options项目中增加一项:

-J-Dorg.netbeans.NbClipboard.level=FINEST

然后重启NetBeans 22,就可以初步解决该问题。

在Github中,还提供了其他几种方法。这里仅供参考。

……
-J-Dnetbeans.slow.system.clipboard.hack=false: The bug seemed to occur less frequently but it still occured.
-J-Dnetbeans.slow.system.clipboard.hack=false and -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 where org.netbeans.NbClipboard.level=FINEST fixes it for most people but not all.
-J-DTopSecurityManager.disable=true: Did not change anything. The bug still occured.
-J-DTopSecurityManager.disable=true and -J-Dorg.netbeans.NbClipboard.level=FINEST: The bug did not occur.
……