Why doesnt a sound play when I change the path?

Hi. I am trying to play a background sound in my program and so far, after searching and reading lots of posts I finally have a "TaDa" sound playing once when the program starts. But what I want is a sound to be looped everytime I start a program. That sound will be in the same folder as the program.
This is the code that I put in public static void main() to play the sound:
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
java_testt b = new java_test();
b.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
b.startApp();
private void startApp()
{playStartupSound();}
private void endApp() {System.exit(0);}
private void playStartupSound() {
Runnable soundPlayer = new Runnable() {
public void run() {
try {                                                                                    
File tadaSound = new File(System.getenv("windir") + "/" + //This is the windows tada sound. All I want is
"media/tada.wav"); //to change the path to another sound
AudioInputStream audioInputStream = AudioSystem
.getAudioInputStream(new FileInputStream(tadaSound));
AudioFormat audioFormat = audioInputStream
.getFormat();
DataLine.Info dataLineInfo = new DataLine.Info(
Clip.class, audioFormat);
Clip clip = (Clip) AudioSystem
.getLine(dataLineInfo);
clip.open(audioInputStream);
clip.start();
} catch (Exception e) {
e.printStackTrace();
Thread soundPlayingThread = new Thread(soundPlayer);
soundPlayingThread.start();
Does anyone know how to choose another sound in the same folder as java_test and make it work with this code because when I change the ath it doesnt run.
Thanks.

Please put your code between the code tags. It's much better readable then.
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
java_testt b = new java_test();
b.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
b.startApp();
private void startApp()
{playStartupSound();}
private void endApp() {System.exit(0);}
private void playStartupSound() {
Runnable soundPlayer = new Runnable() {
public void run() {
try {
File tadaSound = new File(System.getenv("windir") "/" //This is the windows tada sound. All I want is
"media/tada.wav"); //to change the path to another sound
AudioInputStream audioInputStream = AudioSystem
.getAudioInputStream(new FileInputStream(tadaSound));
AudioFormat audioFormat = audioInputStream
.getFormat();
DataLine.Info dataLineInfo = new DataLine.Info(
Clip.class, audioFormat);
Clip clip = (Clip) AudioSystem
.getLine(dataLineInfo);
clip.open(audioInputStream);
clip.start();
} catch (Exception e) {
e.printStackTrace();
Thread soundPlayingThread = new Thread(soundPlayer);
soundPlayingThread.start();
}

Similar Messages

  • Why dose Premier (CS6) Crash when I change the Audio Hardware to System Default?

    I am running a brand new Imac, i7 3.4ghz, 32gb ram and updated.  Full Adobe Production suite installed and updated.  My Audio interface is the Akai EIE Pro with the latest 2.8.18 drivers installed.
    If a launch Audition, After effects, Logic, they all see the audio interface and work seemlessly.  When I launch Premier it does not see the EIE Pro interface and when I change the Default Audio interface to System Default Input/output Premier crashes immediately.  I have tried an earlier version of the EIE Pro drivers with the same results.  It doesn't make sense to me that it would work fine in After Effects but not Premier.
    Here is the following crash report.    Anybody else have this issue or have any ideas on what to do?
    Cheers!!
    Steve
    Process:         Adobe Premiere Pro CS6 [195]
    Path:            /Applications/Adobe Premiere Pro CS6/Adobe Premiere Pro CS6.app/Contents/MacOS/Adobe Premiere Pro CS6
    Identifier:      com.adobe.AdobePremierePro
    Version:         6.0.2 (6.0.2)
    Code Type:       X86-64 (Native)
    Parent Process:  launchd [170]
    User ID:         501
    Date/Time:       2013-07-21 09:29:29.581 -0700
    OS Version:      Mac OS X 10.8.4 (12E55)
    Report Version:  10
    Interval Since Last Report:          104446 sec
    Per-App Interval Since Last Report:  81707 sec
    Anonymous UUID:                      CA3E80BE-8989-2BAE-97EB-5E95F113889C
    Crashed Thread:  0  Dispatch queue: com.apple.main-thread
    Exception Type:  EXC_BAD_ACCESS (SIGABRT)
    Exception Codes: EXC_I386_GPFLT
    [Crash log deleted.]

    Steve, the partial crash log is an unofficial unwritten rule around here.  The cause of the crash is usually near the top of the log anyway.  The hardware profile is at the bottom.  That can be helpful some times.
    But, most of the contents only make sense to software engineers.
    Search for the .plist without ".plist" in the search criteria. 
    Or, look in /System/Library/LaunchDaemons
    Best of luck,
    Jim
    Look, I just edited my post after you replied to it, John.

  • Why doesnt my ipod play when i remove it from my dockstation

    my ipod classic 80gb plays when it is on my dock station, and the battery shows it is fully charged. but when i remove it from the dockstation it wont play and i get a message that says no battery power remains. when i plug it up to my computer itunes doesnt pick it up, and the message on my ipod says please wait very low battery it does this no matter how long i leave it on charge. can anybody please shed some light on this problem for me???

    Hi Truenliving,
    Welcome to Apple Discussions.
    Since you have an iPod Classic (and not a Mini), you may want to post this message in the iPod Classic section : http://discussions.apple.com/category.jspa?categoryID=204
    Someone there may be able to help you better
    A quick search of the Forum reveals this post, with a similar problem (and it seems, a solution... But depending on how old your iPod Classic is, it may still be repairable under warrantee) :
    http://discussions.apple.com/thread.jspa?messageID=7805406&#7805406
    Cheers,
    Awfers

  • Why doesn't siri know how to change the time of a reminder? When asked, "Do you want to confirm or cancel your reminder?" Reply, "Can I change the time to a half hour later?" Siri doesn't know how to respond.

    Why doesn't siri know how to change the time of a reminder? When asked, "Do you want to confirm or cancel your reminder?" Reply, "Can I change the time to a half hour later?" Siri doesn't know how to respond.

    Hi
    In iMovie'11 (version 9.0.x)
    on top menu row - Apple/iMovie/File/Edit/Cut (Can vary dep. on language - in Swedish Apple/iMovie/Arkiv/Redigera/Klipp . . . )
    down Cut menu - Slow playback/Raspid Playback/Re-play in Slow Motion and onvards
    Here one can select the Pre-Set speeds
    Are you familiar with getting 'inspector' to run?
    No - but I guess that Double Click on clip/sequense or ctrl-Click on it might open it.
    Yours Bengt W

  • Why are my apps changing when i change the orientation from landscape to portrait

    Recently, on my ipad mini retina, when i change the orientation from landscape to portrait, the apps change. For example, when i enter a game like impossible and change to landscape to play it and then exit the screen has shifted to either the right or left and shows the first line of the next pages apps. Its kind of like when im in the middle of changing from one page to another but it only changes back to normal when i tough the screen. Im not sure if this has anything to do with the new 7.1 ios but it is becoming really annoying

    I know it is not a specific app problem because it happens when i come out of some of my apps, it doesnt happen all of the time, only sometimes. Also if any of you could help me with another issue with the same device, when i connect to wifi/hotspot i get static on the screen, it is very noticable when i show a dark picture or a large amount of the screen is a dark colour but i wanted to know if this was normal with the ipad mini retina. I have seen discussions about this device having problems connecting to wifi but i havent found any discussions on this. Does anyone know could cause this?

  • Why is it that when I change the contacts on my phone, it changes them on my mom and dad's as well?

    My family and I recently got iPhones for Christmas. One for my dad, one for my mom, and one for me.  We also have an iPad 2.  They are all hooked up to iCloud via one username.  When we got the phones, we had trouble transferring our contacts from our old verizon phones to our new apple ones but we eventually got the contacts we needed.  At first, my mom's phone was not connected to the iCloud account shared by the rest of us and the iPad.  She wanted the calendar from the iPad so I deleted the account on her phone and added the iCloud account that the iPad was using.  All was fine until my dad and I realized that our contacts were wiped from our phones and replaced with my mom's.  I then started painstakingly deleted my moms contacts and replacing them on my own on my phone.  However, contacts were being deleted from my mom and dad's phone at the same time.  It's almost like the three phones are constantly synching with each other.  It would be ideal if we could get all of our contacts back the way they were before my mom changed her account but we would settle for this constant synching to stop. Please give us some direction here, we are new to this. Thanks in advance!

    Why is it that when I change the contacts on my phone, it changes them on my mom and dad's as well?
    Because, as you said "They are all hooked up to iCloud via one username. ". That is exactly what iCloud does.
    You need independent iCloud accounts for each person to maintain independent contact lists.

  • Why does pandora stop playing when i unlock my phone

    Why does pandora stop playing when i unlock my phone?

    Hello wayne1722
    If you are having issues with the Pandora app, check out the article for troubleshooting the issue.
    iOS: Troubleshooting apps purchased from the App Store
    http://support.apple.com/kb/TS1702
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

  • Hello, I update my mac pro to 10.10. Why the photoshop cs6 change to slowly now. When I change the tools like brush to command+Z, It's will be freeze a while. why? and how can I improve?

    hello, I update my mac pro to 10.10. Why the photoshop cs6 change to slowly now. When I change the tools like brush to command+Z, It's will be freeze a while. why? and how can I improve?

    what a long post....Apple, btw, does not read this stuff, so ranting, raving, and complaining here might make you feel good, but it does no good at all. That being said, I, too have a Mac Pro Quad Core Xeon with 6 gigs of ram and an nVidia 8800 GT graphics card (not as good as yours, alas) and I've had no problems at all with it. Yes, it doesn't have Thunderbolt, but maybe we Mac pro owners will get lucky and someone will come out with an adapter (probably not). No, you probably don't have to throw away your Mac Pro, but if you do, I'll take it, for a small "recycling" fee >:-) That was a joke.  Yes, the Mac Pro's future isn't quite clear, YET. Hopefully that will improve very soon. As for not being able to upgrade to Mountain Lion. Don't worry about that too much, Nobody is forcing you to do that.  Your Mac Pro won't quit working if it isn't installed. From what  I've heard, you should give the new OS a chance, and wait to get it, in case there might be some bugs, or stuff not working with the new OS, which has been known to happen. Yes, we Mac Pro owners don't like being treated like mushrooms-kept in the dark, and being fed......... but Apple is Apple and it will do what it does, and there is nothing you or me can really do to change that. All I can say is....trust, have faith, be patient, go for a walk, do something else to take your mind off of this problem. IF apple decides to drop the Mac Pro for good, and that's a big "IF", I think they will anger a whole bunch of people
    which isn't good. However, that hasn't happened...YET. Let us hope that it doesn't
    John B

  • Garage Band,  I am using an MBOX with a digi design audio core as a mic interface to recod into Garage Band.  Now when I Change the preferences to use the MBOX I can not move the recorder slider and there is no sound going into garage band?  Any solutions

    Garage Band,  I am using an MBOX with a digi design audio core as a mic interface to recod into Garage Band.  Now when I Change the preferences to use the MBOX I can not move the recorder slider and there is no sound going into garage band?  Any solutions

    10.5.8 with latest garageband 5.1 with MBOX 1. On Nov 4.09 I did a software update, now i get no output volume or input volume to the computer itself. I get it from head phones from my mbox, but not to the computer. Before the software update It worked great. I've tried upgrading software through digidesign .com, but they dont seem to have one for what i need. any way to get my old garage band back? go from 5.1 to earlier? Or maybe it was the upgrade to 10.5.8. update? Can i go back in time lol?
    Any help would be appreciated
    BTW
    Ive tried all the system sound prefs, and garage band drivers. Back and forth.
    cheers
    ds

  • How i can play smoother HD video files in realtime, when i change the duration in cs6

    How i can play smoother HD video files in realtime, when i change the duration in cs6.

    More information needed for someone to help... please click below and provide the requested information
    -Information FAQ http://forums.adobe.com/message/4200840

  • Disable sound playing when placing phone in the Dock

    Hi.
    I just got a Z3C.
    Is it possible to disable the sound playing when placing phone in the Dock

    SergioPL wrote:
    ronnikn wrote:
    Thanks for trying guys
    Seems I just have to get used to the sound/tone...Which operator version of the phone you have?Could you record (from other phone) a short video of this sound and put it here (or to YT or any other service)?
    My phone has no operator incorporated in it.
    Here's a video of the sound.
    https://vimeo.com/108791963

  • TS3700 why does my music stop playing when i press the sleep/wake buttom? it says the screen turns off but the music should be playing

    why does my music stop playing when i press the sleep wake button? it says that the screen should turn off bu the music should still keep playing

    This is usually a sign that your headphones are not plugged all the way in.  Make sure the white part of the headset is flush with the body of the Nano and no silver from the plug can still be seen.
    If you are 100% positive that the earbuds are all the way in, double check to make sure the headphone jack is clean and clear of debris and/or damage.
    B-rock

  • HT1688 My iphone is neither shown in itunes nor in redsnow .. what is the problem ? It has the black screen and the sound plays when it is plugged into the computer .. I tried to hard reset but only the sound plays nothing is shown is there any solution t

    My iphone is neither shown in itunes nor in redsnow .. what is the problem ? It has the black screen and the sound plays when it is plugged into the computer .. I tried to hard reset but only the sound plays nothing is shown is there any solution to this ?? It says that my iphone is in soft dfu mode and in the my computer > manage>device manager > it shows the apple (dfu mode) having some error sign indicating no software installed i am running windows 8 ..

    Jailbreaking iOS can't be discussed in this forum.

  • Why are animations disappearing when I change the time of the master slide?

    I apologize if this is a stupid question, but I have Adobe Captivate 6, have had Captivate since it was Macromedia Captivate, and I am just stuck.  I imported a .pptx file that a colleague created, and on several pages she has animations.  I went through the .pptx and it looks and works fine. 
    When I import it into Captivate, the animations work fine, but I'm not able to advance each slide until a couple of seconds after it appears.  That won't fly with some of the people at my organization who prefer the clickclickclickclick method of reviewing something.  When I change the timing of the slide or the clickbox or the master slide, the animations sort of get skipped over.
    Can someone please help me?

    Sure, here you go.

  • The screen on my macbook has malfunction. When I change the brightness to zero and return to the first level of brightness it works briefly but then the screen starts to flicker brightness and quickly extinguished.

    The screen on my macbook has malfunction. When I change the brightness to zero and return to the first level of brightness it works briefly but then the screen starts to flicker brightness and quickly extinguished. It seems to be a bad contact, it would not be normal for a quality product that should have, he has less than two years of use. Not because of the bad use or crash. Someone with the same problem or can help me? It's really a contact problem? I've done all the procedures recommended by the online support. Thanks.

    Hey everyone in Apple world!
    I figured out how to fix the flashing yellow screen problem that I've been having on my MBP!  Yessssss!!!
    I found this super handy website with the golden answer: http://support.apple.com/kb/HT1379
    I followed the instructions on this page and here's what I did:
    Resetting NVRAM / PRAM
    Shut down your Mac.
    Locate the following keys on the keyboard: Command (⌘), Option, P, and R. You will need to hold these keys down simultaneously in step 4.
    Turn on the computer.
    Press and hold the Command-Option-P-R keys before the gray screen appears.
    Hold the keys down until the computer restarts and you hear the startup sound for the second time.
    Release the keys.
    I went through the 6 steps above twice, just to make sure I got rid of whatever stuff was holding up my bootup process.  Since I did that, my MBP boots up just like normal.  No flashing yellow screen anymore!!   
    (Note that I arrived at this solution when I first saw this page: http://support.apple.com/kb/TS2570?viewlocale=en_US)
    Let me know if this works for you!
    Elaine

Maybe you are looking for