0

IDE: Intellij
Goal: Use javax.sound.midi.* in my project
Problem: The import statement "import javax.sound.midi.*" gives the error: "package javax.sound.midi does not exist.

When I import the javax.sound.midi in my swing project, everything works perfectly fine. It seems like JavaFX projects can't recognize any imports that start with "javax".

Any help would be appreciated, thank you.

Attempted Solutions: I've tried adding "requires javax.sound.midi." in the "module-info.java" file, but that doesn't work. I've tried going to module settings -> add libraries -> maven -> "javax.sound.midi" , but no search results were found.

  • 4
    I haven't checked, but isn't `javax.sound` part of the `java.desktop` module? – James_D Apr 24 '23 at 16:17
  • 5
    The `requires` directive expects a **module** name, not a _package_ name. And as can be seen in [the documentation](https://docs.oracle.com/en/java/javase/20/docs/api/java.desktop/javax/sound/midi/package-summary.html), the `javax.sound.midi` _package_ is in the `java.desktop` _module_. – Slaw Apr 24 '23 at 17:39
  • When using Java modules, you really should [understand the Java module system](https://www.oracle.com/corporate/features/understanding-java-9-modules.html), trial and error on guessing module names is not the correct way to go. – jewelsea Apr 26 '23 at 06:04

0 Answers0