2 Replies Latest reply: Feb 16, 2008 9:34 PM by 807603 RSS

    No sound when playing .wav from JAR with JMF - JAR file help or alternative


      I'm stuck, and by now pretty dizzy from, trying to play .wav sound files from a JAR file. (The .wav sound files are located in the same directory as, so not included in, the .jar file)
      It seems like JMF is the way to go. But while that works fine when I compile the code with Eclipse, I heard no sound.

      For now I figure it's a problem with my .jar file, and the class-path of its manifest file. I've had problems before trying to construct a .jar file with the SDK executables, namely however I seem to compile the .jar file I get the error message that the main class cannot be found. I solved the problem, or rather cheated my way around it, by making the .jar file by using Eclipse's Export function.
      I try to do that now, and add a Class-Path line to the manifest file and I get the same old error message again: "Could not find the main class. Program will exit". I've read tons of tutorials on making jar files and specifying class-paths, but I just can't figure out what I'm doing wrong. So I need to figure it out once and for all. (Learned myself Java as I go along, so I'm probably missing huge chunks of valuable info.)
      As said, my latest attempt was to add "Class-Path: D:\...\jmf.jar" to the manifest file and that failed miserably. I need some new suggestions :)

      Secondly, since eventually I want this app to run on someone else's computer, and I already saw some headaches mentioned here and there about how to get it to work on other PCs: Is there an easier way to accomplish what I'm trying to do?

      Greetz, and Thx
        • 1. Re: No sound when playing .wav from JAR with JMF - JAR file help or alterna
          You should really factor this into several smaller problems. First figure out how to build a jar file using ANT or the jar utility, don't use Eclipse for distribution, it will perform magic that you may never actually understand.

          Once you have the jar file built, determine where you really want the wav files to be, in the jar, or in a place the user can write to outside the jar. Then provide a way to configure that at run time.
          • 2. Re: No sound when playing .wav from JAR with JMF - JAR file help or alterna
            Aye, found some new gusto, and dove into the jar making business again.
            Got the problem reduced to a difference in classpath indications.

            The program now works, sound and all, with: "java -cp .;MyJar.jar;D:/.../jmf.jar myPackage.MainClass"
            But a problem still occurs when I try to set the Class-Path in the manifest file.
            First of all, when trying any combination of the parts of the above classpath declaration seperated by spaces ("Class-Path: *+.+* *+MyJar.jar+* D:/.../jmf.jar", I've tried it with those in bold-italics and without), I get NoClassDefFoundError when I try to run it. ("java -jar MyJar.jar").
            If I set Class-Path to the same literal text (".;MyJar.jar;D:/.../jmf.jar"), the program runs, but during runtime I get another error:
            Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: javax/media/Manager

            Already glad I got it to run SOME way, but would really like to extend my knowledge by knowing what is causing these last errors and how I should phrase my Class-Path declaration in the manifest file.