添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

There is a class in my project. This class in package javax.swing extends javax.swing.JOptionPane because I want to use some protected methods of JOptionPane.

When the compiler is JDK 8 it works fine. I update the JDK version to 11 then I've got a compile error: Package 'javax.swing' exists in another module: java.desktop.

My IDE is Intellij idea. I opened the Settings--Build,Execution,Deployment--Java Compiler and added an item to 'Override compiler parameters pre-module'. The Module is my project. The compilation options is

--patch-module java.desktop=src -d mypatches/java.desktop/src/java.desktop/javax/swing/Top.java

But it does not work.

My project tree is 'GreatProject/src/javax/swing/Top.java'.

What's the 'src -d' means?

What's the right '--patch-module'?

Starting from Java 9 version, full support for the jigsaw project was added to ensure the project's modularity. This system can cause problems at the compile process if the same names are present in packages.

  • Please, check this topic about the module patching process to adapt your module for javax.swing package.

  • Also, you may try to use Reflection API for getting elements from 'JOptionPane' class.

  • I have seen the patch-module command in OpenJDK website. There is an example. javac --patch-module java.base=src -d mypatches/java.base \ src/java.base/java/util/concurrent/ConcurrentHashMap.java. What does the backslash do? What's the mypatches? – S.Lee Feb 17, 2020 at 7:27

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.