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

117 views Asked by At

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

1

There are 1 answers

0
Phil Freihofner On BEST ANSWER

(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.