Java intellij clipboard backup

霸气de小男生 提交于 2021-01-28 20:34:11

问题


I am writing a program operating on clipboard, and I want to make backup of clipboard contents at startup, and restore it when finished. So it looks like:

data = Toolkit.getDefaultToolkit.getSystemClipboard.getContents(this);
doSomething();
Toolkit.getDefaultToolkit.getSystemClipboard.setContents(data, this);

it works fine in general, but when I copy a part of code from Intellij, and run my program, it throws:

Exception "java.lang.ClassNotFoundException: com/intellij/codeInsight/editorActions/FoldingData"while constructing DataFlavor for: application/x-java-jvm-local-objectref; class=com.intellij.codeInsight.editorActions.FoldingData

Exception "java.lang.ClassNotFoundException: com/intellij/codeInsight/editorActions/FoldingData"while constructing DataFlavor for: application/x-java-jvm-local-objectref; class=com.intellij.codeInsight.editorActions.FoldingData

Exception "java.lang.ClassNotFoundException: org/jetbrains/plugins/scala/conversion/copy/Associations"while constructing DataFlavor for: application/x-java-serialized-object; class=org.jetbrains.plugins.scala.conversion.copy.Associations

Exception "java.lang.ClassNotFoundException: org/jetbrains/plugins/scala/conversion/copy/Associations"while constructing DataFlavor for: application/x-java-serialized-object; class=org.jetbrains.plugins.scala.conversion.copy.Associations

even if doSomething function is empty.

Is it possible to backup ANY content from clipboard? If not, how to handle such problem?


回答1:


"Exception "java.lang.ClassNotFoundException: com/intellij/codeInsight/editorActions/FoldingData"while constructing DataFlavor for: application/x-java-jvm-local-objectref; class=com.intellij.codeInsight.editorActions.FoldingData Exception "java.lang.ClassNotFoundException: com/intellij/codeInsight/editorActions/FoldingData"while constructing DataFlavor for: application/x-java-jvm-local-objectref; class=com.intellij.codeInsight.editorActions.FoldingData"

I had this error - I go to my IntelliJ to

File -> Project Structure

and I switched the module specific SDK from "1.8 java version...." to "IntelliJ IDEA IU -162.1447..." and it's work fine.

I hope I helped you.




回答2:


The error is caused when you copy something from intellij which stores serialized objects on the clipboard. I found a workaround for this. Check this answer



来源:https://stackoverflow.com/questions/36769139/java-intellij-clipboard-backup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!