Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java intellij clipboard backup

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?

like image 454
Com Piler Avatar asked Feb 16 '26 06:02

Com Piler


2 Answers

"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.

like image 173
Iosif Mocanu Avatar answered Feb 18 '26 19:02

Iosif Mocanu


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

like image 40
Shailesh Jain Avatar answered Feb 18 '26 20:02

Shailesh Jain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!