3

i am working on adapting my desktop app to run with jre9 i get

java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: sun/audio/AudioStream

i had some other problems with sun API that i resolved by adding the jvm args --add-exports=java.desktop/sun.awt=ALL-UNNAMED --add-exports=java.desktop/sun.swing=ALL-UNNAMED but in those cases the error was of type java.lang.IllegalAccessError so exporting the model solved the problem.

any idea how can keep using the sun.audio? of course i can try to switch to a different library like javax.sound but i have some legacy code that i rather not touch.

i tried some options like --add-open and --illegal-access but assuming the sun.audio api was removed form the sdk those options won't make any difference

StackzOfZtuff
  • 2,534
  • 1
  • 28
  • 25
Efi G
  • 937
  • 8
  • 15
  • 1
    The sun.audio package was a JDK internal API, it was removed in JDK 9 (see https://bugs.openjdk.java.net/browse/JDK-8050465). JavaSound has been in Java SE since 1.3. – Alan Bateman Mar 01 '18 at 18:32
  • Thanks Alan! Can i use it by importing a specific jar that contains that package? – Efi G Mar 02 '18 at 07:18
  • It was a JDK internal API, I'm not aware of any way to use it outside of JDK 8 and older. – Alan Bateman Mar 02 '18 at 10:17

1 Answers1

2

As Alan Bateman commented, sun.audio packages were removed from jdk9.

I ended up replacing the usage of the sun.audio package in my code.

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Efi G
  • 937
  • 8
  • 15