相关文章推荐
慷慨大方的钥匙扣  ·  JAVA ...·  1 周前    · 
想发财的遥控器  ·  swing ...·  2 周前    · 
近视的剪刀  ·  iOS ...·  9 月前    · 
月球上的煎饼果子  ·  嵌入式 Linux ...·  12 月前    · 
长情的大熊猫  ·  asp是多层架构吗 ...·  1 年前    · 
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.