3 Replies - 930 Views - Last Post: 11 May 2011 - 11:47 AM Rate Topic: -----

#1 sonictrio  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 09-September 09

.jar sound files not playing using ClassLoader

Posted 11 May 2011 - 07:24 AM

Hi, I have a program which - when run through eclipse - plays sound files when told, however when I export to a runnable .jar file using eclipse the sound files do not play.

Here is a snippet of my code:

URL url = this.getClass().getClassLoader().getResource("sounds/eagle.mp3");
try {
      	player = Manager.createRealizedPlayer(url);
      	player.start();
}



The sound files are stored in a "sounds" folder included in the .jar (verified after export). Why is it not playing my sounds?

Is This A Good Question/Topic? 0
  • +

Replies To: .jar sound files not playing using ClassLoader

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2734
  • View blog
  • Posts: 11,513
  • Joined: 20-September 08

Re: .jar sound files not playing using ClassLoader

Posted 11 May 2011 - 08:29 AM

Try


this.getClass().getClassLoader().getResource("/sounds/eagle.mp3");

Was This Post Helpful? 0
  • +
  • -

#3 sonictrio  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 09-September 09

Re: .jar sound files not playing using ClassLoader

Posted 11 May 2011 - 10:51 AM

View Postg00se, on 11 May 2011 - 09:29 AM, said:

Try


this.getClass().getClassLoader().getResource("/sounds/eagle.mp3");


Unfortunately adding the extra forward slash did not solve the problem...
Was This Post Helpful? 0
  • +
  • -

#4 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2734
  • View blog
  • Posts: 11,513
  • Joined: 20-September 08

Re: .jar sound files not playing using ClassLoader

Posted 11 May 2011 - 11:47 AM

Please post jar listing:

jar tf yourjar.jar

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1