Java Sound: devices found when run in IntelliJ, but not in SBT

后端 未结 1 990
忘了有多久
忘了有多久 2021-01-20 11:47

I\'m trying to to use Java Sound API in a Scala SBT-managed project.

Here is a toy app that plays a note.

import javax.sound.midi._

object MyMain ex         


        
1条回答
  •  旧巷少年郎
    2021-01-20 12:09

    SBT runs your application in-process, with some classloader magic, which probably prevents MidiSystem from finding (using SPI) the sound components.

    You can try forking a new JVM to run your application: fork in run := true. See Forking in the documentation.

    Note that:

    • by default it does not redirect input to the application. You can add that with:

      connectInput in run := true
      
    • the forked JVM can be killed by any external tool without problem (using kill or any kind of task manager)

    0 讨论(0)
提交回复
热议问题