Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9139179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:21:14+00:00 2026-06-17T09:21:14+00:00

I am creating a software for personal use titled BatteryBeeper. It will remind me

  • 0

I am creating a software for personal use titled BatteryBeeper. It will remind me to charge the laptop when the charge is whatever I set to be reminded at.

It is supposed to play a sound when the charge hits the set threshold.

I had a look at the answer: sound not playing in jar and my AudioInputStream is constructed similar to what Jigar Joshi mentioned.

However I get a null exception:

java.lang.NullPointerException
    at com.sun.media.sound.SoftMidiAudioFileReader.getAudioInputStream(Unknown Source)
    at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source)
    at demo.BatteryBeeper.setupSoundPlayback(BatteryBeeper.java:169)
    at demo.BatteryBeeper.<init>(BatteryBeeper.java:41)
    at demo.BatteryBeeper.main(BatteryBeeper.java:35)  

Here is my code to load the sound:

public void setupSoundPlayback(){
        try{
            buzzer = AudioSystem.getClip();
            in = AudioSystem.getAudioInputStream(BatteryBeeper.class.
                    getResourceAsStream("sound/buzzer3_x.wav"));
            buzzer.open(in);
        }catch(Exception e){
            e.printStackTrace();
        }

    }  

Here is the code to play it:

public void playSound(){
        buzzer.start();
    }  

What is causing the problem ?

Misc

This is a usual Eclipse project. There is a sound folder under src which has the wave file

Edit

After AlexR’s answer, I changed the path and got a new exception:

javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input stream
    at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source)
    at demo.BatteryBeeper.setupSoundPlayback(BatteryBeeper.java:169)
    at demo.BatteryBeeper.<init>(BatteryBeeper.java:41)
    at demo.BatteryBeeper.main(BatteryBeeper.java:35)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:21:15+00:00Added an answer on June 17, 2026 at 9:21 am

    You problem is not in playing the sound. Your problem is in access to embedded resource. When you are using BatteryBeeper.class.getResourceAsStream("sound/buzzer3_x.wav") you try to retrieve resource located in same package where class BatteryBeeper is. This means that your file is in /demo/sound/buzzer3_x.wav. It seems this is wrong. If your file really is in sound/buzzer3_x.wav use getResourceAsStream("/sound/buzzer3_x.wav") (pay attention on the leading slash in the path).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am in process of creating a software for dumping plain text of whatever
I'm creating some software to keep my students on task. I've set it up
I'm creating a piece of software (written in C#, will be a windows application)
I am creating a software application that is able to update itself. After the
I am creating a forum software. I want admins and mods to be able
I'm creating custom forum software for a site I'm building, which includes 2 tables
I am creating a script to configure and launch software. My current application requires
I'm creating .net websites against a CMS server using the API of the software
So...I am creating software for a university. The purpose of the software doesn't matter.
I am creating a software project in which most business objects are stored in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.