Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

359
Views
Playing audio in IDEA works but when compiled into a jar it errors

When running this in IntelliJ IDEA it works fine, audio plays however when I build this as an artifact it errors on

play.close();

This is the stacktrace

java.lang.IllegalStateException: line already closed at org.classpath.icedtea.pulseaudio.PulseAudioClip.close(PulseAudioClip.java:241) at me.com.test.main.playAudio(main.java:37) at me.com.test.main.main(main.java:50)

public static Boolean playAudio(File localSoundURL) {
    Clip play = null;
    try {
        AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(localSoundURL);
        play = AudioSystem.getClip();
        play.open(audioInputStream);

        FloatControl volume = (FloatControl) play.getControl(FloatControl.Type.MASTER_GAIN);
        volume.setValue(6.0f);

        play.start();
        play.drain();
    } catch(UnsupportedAudioFileException |IOException | LineUnavailableException ex) {
        ex.printStackTrace();
        return false;
    } finally {
        try {
            assert play != null;
            play.close();
        } catch (Exception exp) {
            exp.printStackTrace();
        } finally {
            return true;
        }
    }
}

public static void main(String[] args) throws InterruptedException {
    System.out.println(playAudio(new File(FileSystemView.getFileSystemView().getHomeDirectory()+"/Music/tahdah.wav")));
}
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!