javaintellij-ideajavasound

Package 'javax.sound.midi' is declared in module


When I add this in my Java app in IntelliJ

import javax.sound.midi.*;

I get this error "Package 'javax.sound.midi' is declared in module 'java.desktop', but module 'com.example.music' does not read it"

I have read online that javax.sound is part of the OpenJDK 20 ...

Have you an idea of why I get this error

Ed


Solution

  • (Posted after engaging in clarifying questions.)

    Sometimes an error message like this occurs because the required module is not listed in the module-info.java file.

    According to the OP, adding the following line to module-info.java:

    requires java.desktop;
    

    solved the issue.