Okay, so I’ve managed to get it playing .oggs inside eclipse, but it refuses to play .oggs when it’s in a jar setting. .wavs seem to work inside a .jar, but they are extremely inefficient and take up too much space.
when you make the jar, are you adding another level of compression to the oggs? This might have an effect. I haven’t tried to do this in a long time, so I am only guessing.
If you are using exactly the same code and file locations and wav works and oggs don’t, the only other thing I can think is that maybe needed library files aren’t getting included in the jar. I can’t recall if TinySound includes the needed files for ogg or if they are an additional import that is needed.
Is there an error message when the sound should play (when the jar is run from a command line)?
where fileName.jar is the name of your jar file. If Java throws any exceptions, they should show up as output on the console output unless you wrote code to catch and ignore them.
Before, you said the program runs fine in Eclipse. Is this a new error? Is this a warning that occurs when you try to run the program (but the program still runs)?
Or is this a message that occurs when you make the jar file?
Have you done anything custom or special to configure how this program is built or what it calls when it is run?
This error happens when I make the .jar file. And as far as I am aware, I have done nothing custom to the program. (Aside from using BuildPath to hook it up to the libraries.)
The only suggestion I can think of at this point is to try remaking the program as small as possible while still generating the error. At some point it the answer will either become clear, or you’ll have posted code that we can use to recreate the error (if the error is in the code and not in Eclipse settings).
I’m assuming the error game up while making the Jar, not while running the jar. When you run the jar from the console, is there a useful error message?
the jar file was in the same directory, yes? If it is not in the same directory, then the address has to be included with the name. My apologies if I am indicating something that you already know.
Also, I’m not sure on naming conventions, and if Windows is okay with having a space in the name. Seems to me that it is safer to eliminate spaces.
The name of the file has to be exactly right, including case. If your file is “SlimeFighter 4.JAR” and you specify “SlimeFighter 4.jar” it will give you the “unable to access” error message. Also, “Slimefighter 4.JAR” will fail.
Maybe it would be good to just save a “HelloWorld” program as a jar and run it from the command line, if you have never done this before. It’s a crucial skill to be able to troubleshoot: e.g., make simpler cases to try and isolate where a problem lies.
Just now, I took a file of mine which uses Java audio and renamed it to include a space in the name. The original file is Tanpura.jar, and the copy is “Tanpura 1.jar”.
These commands worked just fine:
java -jar Tanpura.jar
java -jar "Tanpura 1.jar"
So the problem is probably not due to the space in the name. Having a space in the name still makes me uneasy, though. For example, the easy-to-make error of forgetting to include the “” marks gives the following:
IF you get the following result:
(1) jar with wavs plays from console with no errors
(2) exactly the same jar with oggs for wavs (from console) has an error message,
THEN we should have a basis for getting to the root of this mystery.
I’m guessing that the issue is with the libraries not hooking up and Java getting confused as to what the main class is. However, as far as I know, the only main class is the one I set up. In Eclipse, where I’ve hooked up the libraries using BuildPath, everything compiles correctly.