• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where to park my abc.wav file in the Netbeans IDE

 
Dave Elwood
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a nice little app done with a wav file to make a noise.

Now I'd like to clean & build the whole thing into MyApp.jar with NetBeans.

Problem is.....where do I put my abc.wav file? Must I modify an xml for this?

 
Kevin Moody
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First create a new Java package like com.dave.elwood.resource.sounds within your main project. Then just copy/paste 'abc.wav' file into that new package.
 
Maneesh Godbole
Saloon Keeper
Posts: 11061
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You also need to remember, while access packaged resources in a jar, you should be accessing the using getClass().getResource()
 
Dave Elwood
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I put my Bang.wav into a seperate package, "Resources"



and this doesn't compile.....what to do??
 
Maneesh Godbole
Saloon Keeper
Posts: 11061
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Elwood wrote:
and this doesn't compile.....what to do??

What error message did you get?
 
Dave Elwood
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correction - it compiles and builds but when running this comes out :


the line MyWidgets.MyPanel.makeCrashSound(MyPanel.java:1337) is the line after :


the getResourceAsString(....) returns a null so the next line (line 1337) it hit with NullPointerException

This is a jpg of my resource tree structure
Resource Tree.jpg
[Thumbnail for Resource Tree.jpg]
Bang.wav parked in a Resources package
 
Maneesh Godbole
Saloon Keeper
Posts: 11061
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is the file really called resources.bang.wav ? Or is the file situated under resources/bang.wav?

 
Dave Elwood
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is this : resources/bang.wav

Here is the real file tree structure....under the folder resources is bang.wav

File Structure.jpg
[Thumbnail for File Structure.jpg]
file structure
 
Rob Spoor
Sheriff
Pie
Posts: 20545
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Elwood wrote:It is this : resources/bang.wav

So use Resources/Bang.wav, not Resources.Bang.wav.
 
Maneesh Godbole
Saloon Keeper
Posts: 11061
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Elwood wrote:It is this : resources/bang.wav


What I meant to hint to you was check your code. Are you trying to load the same file in the code?
Do you think Resources.bang.wav and resources/bang.wav are the same?
 
Dave Elwood
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you think Resources.bang.wav and resources/bang.wav are the same?


which one of you told me this? :

First create a new Java package like com.dave.elwood.resource.sounds within your main project. Then just copy/paste 'abc.wav' file into that new package.


it works :
InputStream in = this.getClass().getResourceAsStream("../Resources/Bang.wav");

Thanks guys.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic