S
S
ShOlegSanta2019-04-23 07:14:23
Java
ShOlegSanta, 2019-04-23 07:14:23

Why is there an error message when importing sun.swing in Java12?

I set import sun.swing.MenuItemLayoutHelper; the message package sun.swing is not visible
(package sun.swing is declared in module java.desktop, which does not export it to the unnamed module) appears. The java.desctop module has the sun.swing package. Help me understand what's going on.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2019-04-23
@zolt85

The fact is that modules have appeared in Java since version 9. To connect modules, you need to describe them in your application using the module-info.java file, for example:
requires java.desktop;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question