java - sound will play in eclipse but not in exported jar file -


sound not play when run jar, when run in eclipse.

here load clips: (the files loaded directory of jar, not within jar)

public void init(){     system.out.println("grabbing music");     string currentdir = new file("").getabsolutepath();     name=new file(currentdir+"\\music\\").list();     clip=new clip[name.length];     soundfile=new file[name.length];     for(int x=0;x<name.length;x++){         system.out.println(currentdir+"\\music\\"+name[x]);         try {             soundfile[x]= new file(currentdir+"\\music\\"+name[x]);             audioinputstream sound = audiosystem.getaudioinputstream(soundfile[x]);             dataline.info info= new dataline.info(clip.class, sound.getformat());             clip[x] = (clip) audiosystem.getline(info);             clip[x].open(sound);             clip[x].addlinelistener(new linelistener(){                 public void update(lineevent event) {                     if (event.gettype() == lineevent.type.stop) {                         event.getline().close();                     }                 }             });         } catch (lineunavailableexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         } catch (unsupportedaudiofileexception e) {             e.printstacktrace();         }     }  } 

i not errors when running in eclipse. there should no possibility of invalid directory error, wrong?

-when jar run in cmd no errors nor stacktraces, loading files, isnt running when clip.start() called. way im loading files in not compatible runnable jars.

edit: feel loading audio wrong, hence why pasted code used load files in. in searches haven't seen use file load in sound file. wonder if problem?

-also switching embedded resources not work.

the reason sound not playing because not being compiled runnable jar , cannot found. best way have compile runnable jar create source folder in eclipse, , add sound file in there. compiled jar


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -