How to handle missing Swing PLAF classes in Java 11?
Asked Answered
W

1

10

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?

Wedekind answered 22/11, 2018 at 19:40 Comment(2)
Related reads Internal APIs encapsulation, Add a public API to create a L&F without installation, Inaccessible and unused classes can be removed from java.desktop moduleSift
Non-Windows builds no longer include the Windows LAF, see: bugs.openjdk.java.net/browse/JDK-6461834Genu
W
9

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.

Wedekind answered 26/11, 2018 at 10:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.