Getting TinySound to play .oggs in a .jar

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.

Any ideas?

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)?

How do I run it from a command line?

Anyways, TinySound only runs .oggs if I hook up the needed libraries by using “Build Path”. These librarues are JOrbis, Tritonus_Share and Vorbisspi.

The command for running a jar is as follows:


java -jar fileName.jar

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.

It most certainly will not break anything. Worst case would be that the GZ compressed OGG will have grown a tad in size.

Could you post the code you’re using to load them?

Kev

Surething.

///sound initialization start///
		TinySound.init();
		System.out.println("Loading music...");
		///music///
		Music debugmenu = TinySound.loadMusic("/resources/sound/music/debugmenu.ogg");
		Music gameover = TinySound.loadMusic("/resources/sound/music/gameover.ogg");
		Music maintheme = TinySound.loadMusic("/resources/sound/music/maintheme.ogg");
		Music win = TinySound.loadMusic("/resources/sound/music/win.ogg");
		///music end///
		System.out.println("Music loaded successfully...");
		
		System.out.println("Loading SFX...");
		///sfx///
		//companions//
		Sound dogb = TinySound.loadSound("/resources/sound/sfx/companions/dogb.wav"); //needs to be converted to .ogg
		System.out.println("Companions SFX loaded...");
		//fight sfx//
		Sound swordsh = TinySound.loadSound("/resources/sound/sfx/fighting/sword_sheath.wav"); //needs to be converted to .ogg
		Sound swordst = TinySound.loadSound("/resources/sound/sfx/fighting/sword_strike.wav"); //needs to be converted to .ogg
		System.out.println("Fight SFX loaded...");
		//merchant sfx//
		Sound coins = TinySound.loadSound("/resources/sound/sfx/merchants/coins.wav"); //needs to be converted to .ogg
		System.out.println("Merchant SFX loaded...");
		//player sfx//
		Sound dpotion = TinySound.loadSound("/resources/sound/sfx/human/drinkpotion.wav"); //needs to be converted to .ogg
		Sound inventory = TinySound.loadSound("/resources/sound/sfx/human/inventory.wav"); //needs to be converted to .ogg
		Sound potions = TinySound.loadSound("/resources/sound/sfx/human/potions.wav"); //needs to be converted to .ogg
		Sound run = TinySound.loadSound("/resources/sound/sfx/human/running.wav"); //needs to be converted to .ogg
		Sound walk = TinySound.loadSound("/resources/sound/sfx/human/walking.wav"); //needs to be converted to .ogg
		System.out.println("Player SFX loaded...");
		//status effects//
		Sound explosionsfx = TinySound.loadSound("/resources/sound/sfx/slimes/voltaicexplode.wav"); //needs to be converted to .ogg
		System.out.println("Status effects SFX loaded...");
		///sfx end///
		System.out.println("SFX loaded successfully...");
		
		System.out.println("Loading voices...");	
		///voices///
		//remir//
		Sound remirfail = TinySound.loadSound("/resources/sound/voices/remir/remirfail.ogg");
		Sound remirintro = TinySound.loadSound("/resources/sound/voices/remir/remirintro.ogg");
		Sound remirnogold = TinySound.loadSound("/resources/sound/voices/remir/remirnogold.ogg");
		Sound remirthanks = TinySound.loadSound("/resources/sound/voices/remir/remirthanks.ogg");
		Sound remirstolen = TinySound.loadSound("/resources/sound/voices/remir/remirstolen.ogg");
		System.out.println("Remir voices loaded...");
		///sound initialization end///
		System.out.println("Sound initialized successfully...");

During compiling, Eclipse throws out the “Could not find main method from given launch configuration.”

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.)

It means your launch/run configuration is incorrect. Make sure you’re specifying the correct one in the jar wizard.

Im using the default configuration, which was working fine with .wavs

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?

Error: Unable to access jarfile SlimeFighter 4.jar

When you ran the command

java -jar SlimeFighter4.jar

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.

I went and moved it into C:\ and then ran

java -jar "C:\SlimeFighter 4.jar"

I got the exact same error.

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:

Error: Unable to access jarfile Tanpura

I’ve removed the space and ran the command java -jar SlimeFighter4.jar and the same error popped up.

Maybe I should stick to using .wavs

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.