Getting java.lang.ClassCastException: javax.swing.KeyStroke when creating a JSplitPane
-
02-07-2019 - |
Question
I'm getting a random unreproducible Error when initializing a JSplitPane in with JDK 1.5.0_08. Note that this does not occur every time, but about 80% of the time:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.KeyStroke
at java.util.TreeMap.compare(TreeMap.java:1093)
at java.util.TreeMap.put(TreeMap.java:465)
at java.util.TreeSet.add(TreeSet.java:210)
at javax.swing.plaf.basic.BasicSplitPaneUI.installDefaults(BasicSplitPaneUI.java:364)
at javax.swing.plaf.basic.BasicSplitPaneUI.installUI(BasicSplitPaneUI.java:300)
at javax.swing.JComponent.setUI(JComponent.java:652)
at javax.swing.JSplitPane.setUI(JSplitPane.java:350)
at javax.swing.JSplitPane.updateUI(JSplitPane.java:378)
at javax.swing.JSplitPane.<init>(JSplitPane.java:332)
at javax.swing.JSplitPane.<init>(JSplitPane.java:287)
...
Thoughts? I've tried cleaning and rebuilding my project so as to minimize the probability of corrupted class files.
Edit #1 See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6434148 - seems to be a JDK bug. Any known workarounds? None are listed on the bug entry page.
Solution
After doing some Googling on bugs.sun.com, this looks like this might be a JDK bug that was only fixed in JDK 6.
See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6434148
OTHER TIPS
Same exception had got thrown when i had upgraded java verion and db visualizer dint support jre7. and since Support for Java 7 was introduced in DbVisualizer 8.0 for Windows and Linux/UNIX.
Support for Java 7 on Mac OS X was introduced in DbVisualizer 9.1.
So Solution that worked for me : Windows/Unix/Linux: In the DbVisualizer installation directory there is an .install4j directory, In this directory create a file named pref_jre.cfg if it doesn't already exist, Open the file in a text editor, Add the complete path to the root directory for the Java installation you want to use. Example: C:\Program Files\Java\jre7
java.lang.ClassCastException: javax.swing.KeyStroke cannot be cast to java.lang.Comparable....
If you are getting above error after installing java 7 in dbviz then add Environment variabbles like: 'DBVIS_JAVA_HOME' as a 'Variable Name' and java path like for ex. "C:\SWDTOOLS\IBM\RAD85\runtimes\base_v7\java"