Play WAV files into the .jar

Hello,
I'm doing small application Java with Netbeans.
I need is to play .wav file sounds are incorporated into the jar.
I do not want to use external libraries or external sound files, etc.. I want to go with my .JAR to the office, home, etc ... just need the JAR to hear the sounds.
I've created a folder "Sounds" in "src" and in that place I have my sounds. (Project / src / sounds). It's a way to incorporate a JAR file, or am I wrong?? Run independently of the sound files.
At the time of reproducing the sound I do the following:
Clip sonido = AudioSystem.getClip();
File f = new File(getClass().getResource(/Sonidos/alarma.wav).toURI());
sonido.open(AudioSystem.getAudioInputStream(f));
sonido.start();
If I run the program with netbeans, I play sounds, but which only transfer my .JAR to another computer, does not play ...
Any ideas?
Thank's.

I don't understand, before I had done as you have written me, but did not work, but now it works.
Problem solved. Thank's.
Posting the code here:
InputStream path = getClass().getResourceAsStream("/Sonidos/alarma.wav");
try
sonido = AudioSystem.getClip();
sonido.open(AudioSystem.getAudioInputStream(path));
sonido.start();
}catch(Exception fail)
System.out.println(fail);
Edited by: 892291 on 19-oct-2011 10:37

Similar Messages

  • How to play wave files from a jar archive?

    Dear friends,
    I have a .jar archive with several .wav files, and I would like to play them without extract these files.
    This is possible to do? If yes, please show me how to do this.
    Thank you for your attention,
    Augusto Nunes

    This discussion of getResource is very useful: http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html#getresource

  • How to return Firefox to playing .wav files without the vlc plug-in?

    Win XP, Firefox 33.11. In an html document are links to PCM, 16 bit .wav files and
    other links to .mp3 files. Opening the document with Firefox and clicking on an .mp3 link
    plays in the `native' Firefox player OK. However clicking on a .wav link seemed to fail to
    play. Using Tool/Options/Applications, wav files were associated with VLC. Now clicking
    on a .wav link plays OK in a Firefox screen displaying the vlc logo.
    However, later the following was found this under the Firefox help information
    "Firefox can play the WAV container format (.wav, .wave file types) containing uncompressed
    audio in PCM at 8 or 16 bits per sample".
    It seems the .wav files should play with the `native' Firefox player.
    How can the link to vlc be removed. Removing the plug-in is not a solution as it is used
    for many other file types.

    Firefox will only use the HTML5 media player when the AUDIO tag is used.
    If EMBED or OBJECT is used then Firefox will always use a plugin.
    *http://developer.mozilla.org/Apps/Build/Audio_and_video_delivery

  • Is it possible to import your own wave files into the EXS-24?

    I have been wondering if it is possible to create your own samples and import them into the EXS-24.
    I just created some short wave files of a voice and want to recall them whenever I need them. Is that possible? And if yes? How exactly?
    Thanks!

    Sure, open an empty patch in EXS, hit the edit button and drag the wavs from your finder into the sample zone, a menue will show up asking you what samples to map to which keys. Read the manual about the EXS, it sure helps...

  • Storing  WAVE file into database from sql plus.

    dear all
    I have create a table with two attributes,sl_no number and song long raw type.
    what will be the insert command to insert a .wav file into the database.if not then you can give me some alternate solution also.
    thanks.

    You can use DBMS_LOB.LoadFromFile, I assume you would load these as a BLOB.
    The documentation can be found on technet at
    urlhttp://technet.oracle.com/docs/products/oracle9i/doc_library/901_doc/appdev.901/a89852/dbms_20b.htm#1009007
    [\url]
    An alternative would be to use java to read the file from the file system, and serve it up as a CLOB or BLOB, and INSERT it into the database from there.
    Good Luck,
    Eric Kamradt

  • How can  I include my database file into my jar file?

    Hi,
    I am doing several tests for the jar command....
    I tried to put the database file into my jar file, but when the program run, it just couldn't find the database file, so how may I include the database file into the jar file? Not only that, it also can't find the policy file etc.

    sorry, I think I found the solution, I should have had read the API more carefully.

  • I thought the Style 100 could play .wav files !!

    which is why I bought one!
    !!! Just deli'vered. I've tried all the suggestions in the forum messages. None work.
    I have used drag and drop into the music folder and the recordings folder. The files don't show up in the Zen folders although they are visible when I explore the Zen like a thumb dri've. What's up!!!
    Your specifications say it plays .wav files thiis is apparently incorrect information. Creative Centrale does not recognize .wav files either.
    Are you going to change the spec or provide support for playing .wav *as advertised?*
    Thanks

    Hi,
    There are many different kinds of compression formats for wav files. The ZEN Style 00 supports IMA-ADPCM compression. Please check the compression format of your wav files.

  • How do I add a jar file into the build path of the compiler?

    Hey,
    I'm trying to import a jar file into the build path of the compilation process, but it does not find the packages or the classes that are in it.
    I think I don't add it right...
              ArrayList<String> options=new ArrayList<String>();
              options.add("-d");
              options.add(targetDirectory);
              options.add("-classpath");
              for(String str:includeDirectory)
                   options.add(str);
              if (!compiler.getTask(writer, fileManager, diagnostics, options, classes, compilationUnits).call());
                    ....and I've tried this way:
         public void setTargetDirectory(String targetDirectory) {
              this.targetDirectory = "-d " + targetDirectory;
         private void compile(Iterable<? extends JavaFileObject> compilationUnits) throws Exception {
              ArrayList<String> options = new ArrayList<String>();
              options.add(targetDirectory);
              String classPath="-cp ";// tried this also with "-classpath"
              for (String str : includeDirectory)
                   classPath+=str+":";
              options.add(classPath);
         if (!compiler.getTask(writer, fileManager, diagnostics, options, classes, compilationUnits).call())
              // throw new Exception("Compilation Error");
         }Thanks in advance,
    Adam.
    Edited by: Adam-Z. on Feb 24, 2010 5:41 AM
    Edited by: Adam-Z. on Feb 24, 2010 5:42 AM

    Thank you for your reply,
    Q: Are there .class files in that directory in that jar file? (the compiler doesn't ( can't )) look for directories, it can just look for specific files , and scan to get a list of all files matching certain criteria. So if there are no class files, it will say the package doesn't exist, even if there is a directory, possibly containing other files.yes there are class files in the jar, the tree structure:
    j2MeDataChunkGenerator_Plugin\(lots of class files)
    META-INF\manifest.mf
    and thats it.
    , your code will only work on windows because other platforms use a different path separator. You should use java.io.File.pathSeparator not explicit ';" when building your classpath. (this is unrelated to your problem, but you should correct it)will do, thanks.
    Q: Is that error in your post formatted by your own diagnostics? (we could possibly help you better if we didn't have to guess!!)I would not post my own error code, this text is generated by the compiler diagnostic.
    {code}
         System.err.println(" Error details: " + diagnostic.getMessage(null));
    {code}
    Q: Is line 3 of ImageCroper_Editor.java (sic) an import statement? (we could possibly help you better if we didn't have to guess!!)it is an import error... didn't the error message stated that it is an import problem? wired, I'm sure before it did. anyway it is an import error.
    Also you don't show us what the variable includeDirectory is in terms of type, and contents, that might be helpful. (we could possibly help you better if we didn't have to guess!!)It has only one String object: "D:\%Important Documents\WorkSpaces\PacMan\ApplicationManager\Plug-in\Data Chunk Designer.jar"
    the last file on the classpath list.
    Q: Have you proven this? that i did post, in this long line of text.
    Q: Is the compiler finding other classes (in other packages) in that same jar file?No. all the class files are in the jar, they all have entries that start with "j2MeDataChunkGenerator_Plugin\*.class", and since I get 47 errors I guess it does not load any other class.
    thank you for you comments, the problem with having these errors, is that I can't even get a piece of information where this error is coming from, only that it is an import loading error package not found, what does that mean? that the jar was not loaded in compilation(no error about this), that the jar is corrupted(no error about this), that the path is incorrect(it is correct I made sure), that there is no such package in the jar(There is), that the compiler does not load the package(does it even do that?), really I can't even guess why this happens, I've been at this on and of all day today, really annoying.
    Thanks,
    Adam.

  • How to import jar & exp file into the eclipse 3.1 + jcop

    hi, I am new to the javacard technology.
    I have implementing applet by using eclipse 3.1 + jcop plugin.
    recentlly, i got jar and exp file from someone. and I have to import given two files in the my applet.
    Q1. but i don't know how to use(import) two files into the elipse.
    and...
    I have tried to put the export file structure in the build path, but I am still getting the same error:
    Q2. "resolving constant-pool of clazz cash/ccash; failed: no such clazz cash/ccash;", what means?
    anyone help me~plz!
    many thanks..
    lsh.
    Message was edited by:
    neonoble

    1) In the Package explorer right-click the project you want to import the jar files into.
    2) Click import
    3) Select Archive file in the Import dialog box and click next
    4) Browse to the jar file and select it
    Socx

  • How do I read the images I bundled into the jar file?

    I just wrote an applet that uses
         Toolkit tk = Toolkit.getDefaultToolkit();
         tk.getImage("blah.gif");to load a bunch of image files. The class file and gif images were bundled into a jar file to minimize the number of connections the browser has to make to the server.
    The applet works fine in appletviewer but trips a java.security.AccessControlException: access denied (java.io.FilePermission select.gif read) when run in a browser. I know you normally use Applet.getImage(URL) to load images but wont that circumvent the JAR file and make a seperate connection to the server for each image? That would defeat the purpose of using a JAR file.
    How do I access the image files I bundled into the JAR file?

    From your Applet class, write the following:
    URL imgUrl = getClass().getResource("blah.gif");
    Image img = getImage(imgUrl);The returned URL will be from the Applet class ClassLoader, which will look into the specified archive (jar) file.

  • Visual wave files in the play bar

    How do I bring back the visual wave files in the play bar? They've disappeared since the last upgrade.

    On my 8 year old iTunes there's a little triangle on the left you click to change displays.  Have you tried clicking around on things there?

  • Mixing external wave file into video

    I've recorded a video including sound of a mandolin being played.  At the same time I recorded the sound with my external recorder which resulted in a wave file of better quality that the sound from the camera.  I would like to import the video and the externally recorded wave file into a project, line up the external wave file with the sound recorded by the video camera and then delete the sound recorded with the video camera so I end up with a video that has the sound from the external recording system.  Any recommendations on a good approach to accomplishing this task?

    There's information here about how to use the new merged clips features in Premiere Pro CS5.5 to merge the audio from an external source with the video from the camera.

  • Error Playing .wav file on RHEL 4 using JMF

    Hi,
    We are using jmf api to play wav files on our application deployed on rhel version 4. But we are receiving the following error
    **"Cannot find a Processor for: myfolder/myAudio.wav" --->
    this exception is comming from javax.media.Manager
    throw new NoProcessorException("Cannot find a Processor for: " + source);"**.
    Any ideas what could be issue with this, am I missing some drivers/processor for wav files? I did a default jmf studio installation.
    Thanks and Regards
    Vikram Pancholi
    Edited by: vpancholi on Sep 8, 2009 8:51 AM

    If we take a look at the supported formats page...
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/formats.html]
    And the WAV file is supported by the cross-platform pack, AKA, jmf.jar.
    If you're unable to open a WAV file, I'd say it's most likely because you don't have JMF.jar on your library path. You can fix that at runtime with the switch -djava.library.path=<whatever>
    That's what I would say the issue is.

  • Can iPod play WAV files

    I have the All Music Converter and have converted some of my iPod music files to WAV. However, I can't get iTunes to accept the files. Can iPod play WAV files? Does anyone know how to get them to transfer into iTunes? Thank you.

    Uncompressed WAV files are on the list of compatible formats, has there been any compression applied to the files you have converted?
    iPod 101: Which Files Work With iPod and iTunes
    iPod: About compatible song formats
    iPod shuffle: Compatible audio formats

  • Play wav file on PDA using JMF

    Hi all,
    I need to play wav files on a PDA so I installed J9 on the PDA and downloaded either JMF crossplatform and JMF for windows (version jmf 2.1.1.e for both of them).
    I included in the classpath the jmf.jar from JMF crossplatform and sound.jar from JMF for windows (the JMF crossplatform doesn't have the sound.jar and jmf.jar requires some classes contained in it).
    When I run my testing application I have such an error:
    Unable to handle format: LINEAR, 8000.0 Hz, 8-bit, Mono, Unsigned, 8000.0 frame rate, Framesize=8 bits
    Failed to prefetch: com.sun.media.PlaybackEngine@287a287a
    Error: Unable to prefetch com.sun.media.PlaybackEngine@287a287a
    I have the same error playing wav files with different features (8 or 16KHz, 8 or 16 bits ).
    Can anyone help me?
    Any suggestion is welcome. Thanks in advance!
    Message was edited by:
    pirascrs

    not really I have seen it. The only buyable version left is IBM j9. All the rest basically are sold to handset manufacturers.
    Its hectic out there. I still cant play audio on J9 to build a simple tourist guide!!!!
    javajoom is for wtk21 - hello its 2007.
    Oh well lets toss pda's out of the window along with Microsoft's OS and use smart phone OS - or should I toss J2me and start on C# to be on the safe side???
    Has anyone an answer?

Maybe you are looking for

  • GRC 10.0 / PI 7.3 - SEFAZ PR

    Boa tarde, pessoal, tudo bem? Estamos configurando a SEFAZ do PR no PI, porém não estamos conseguindo nem mesmo consultar o Status de Serviço da SEFAZ PR, as outras, SP, RJ, SE, CE conseguimos normalmente. Fizemos um teste, pegamos o Webservice da SE

  • Windows 7 or itunes not detecting my ipod.

    My ipod (5th gen) was fine working on windows vista 32bit, but i recently bought a brand new computer, operating system windows 7 premium 64bit. Tried most things, resetting ipod or using disk mode has no effect either. Plugging my ipod in never got

  • Error unable to create jar cache in /tmp directory!

    I using tomcat4.0.2,but when I start the tomcat from %catalina_home%/bin using startup.bat, in the startup console printing "error unable to create jar cache in /tmp directory: java.io.IOException: System cant find the direct", and tomcat can be star

  • 40gb Nomad Zen Xtra charging prob

    When I've tried to charge it lately the battery icon doesnt appear, a little power cable icon appears instead, after a few moments it goes away and the player turns off, any ideas anyone??

  • IMovie '08 se cierra inesperademente cuando importo desde la cámara

    Hola a todos en el foro espero que me puedan ayudar Cuando importo a imovie '08 desde la camara de video despues de pocos minutos se cierra inesperadamente. He leido varios post sobre esto que dice sobre divx perian flipmac4 pero no me da resultado a