• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic