• Post Reply Bookmark Topic Watch Topic
  • New Topic

Uanble to run Sound file after building Jar file. i am using Jlayer  RSS feed

 
Jaspinder Virdee
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello every one
i am having bit problem in my first java game project. my program works very well in netbeans before building jar file. My sound files dont work in .Jar

i created some common classes(BackGroundMusic.java and Music.java) for 2 games Soundtoguess and ImagetoGuess
then as both game need to acess files from different folder so i created classes for both games (named SoundtoGuess.java and PhototoGuess.java)
then i created objects of both these in my actuall game and run them accorindingly..

like
SoundtoGuess NowAnimal = new SoundtoGuess("Lion");
NowAnimal.SoundFile.start();

but it is not working in jar file.


My directory is like this

Parent Folder

PsychOut
-->Build

-->dist

-->nbproject

-->SoundLibrary
---------------->jlayer.jar


-->src
------->Data

------->CommonClasses
-------------------------->BackGroundMusic.java
-------------------------->Music.java
-------------------------->ReadTextFile.java

------->Images
------------------------->IdentifySound//folder for images of IdentifySound game
------------------------->IdentifyImages//folder for images of IdentifyImages game

------->Sounds
------------------------->IdentifySound////folder for Sounds of IdentifySound game
------------------------->IdentifyImages//folder for Sounds of IdentifyImages game

------->IdentifySound
------------------------->SoundtoGuess.java
------------------------->Jungle.java

------->IdentifyImages
------------------------->PhototoGuess.java
------------------------->IdentifyPhoto.java

------->test


coding of files are as below

First Common Classes

Music.java



BackGroundMusic.java



PhototoGuess


SoundtoGuess






and in file i am creating many different object of Soundtoguess and ru it like
SoundtoGuess NowAnimal = new SoundtoGuess ("Lion");
NowAnimal.SoundFile.start();


it works fine in neytbeans with no error.. but not in jar file.. please give me detailed answer thank you verymuch
Untitled.png
[Thumbnail for Untitled.png]
jar file opened with winZIP
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should definitely check out how Class.getResource works.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!