How to handle missing Swing PLAF classes in Java 11?

9.2k views Asked by At

For some reason we use com.sun.java.swing.plaf.windows.WindowsComboBoxUI class which worked on Windows/Linux/Mac OS platforms with Java 5.0 through Java 8.0

Starting with Java 10 and Java 11 (we will stick to it as LTS) this class not visible to classloader:

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/java/swing/plaf/windows/WindowsComboBoxUI
at xxx.YYY.main(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.sun.java.swing.plaf.windows.WindowsComboBoxUI
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 1 more

How can we get it working?

1

There are 1 answers

0
Barat Sahdzijeu On BEST ANSWER

We were able to replace com.sun.java.swing.plaf.windows.WindowsComboBoxUI in the code with javax.swing.plaf.basic.BasicComboBoxUI and it seems working fine.