Hello Guest

Another WaveData.create() issue.

  • 8 Replies
  • 14681 Views
Another WaveData.create() issue.
« on: March 08, 2010, 12:35:18 »
Hi there I am curious I have read at least once of others having issues with this problem I am compiling code from the first tutorial on producing audio but the line..
WaveData waveFile = WaveData.create("Battle.wav"); (I used the cooler noise)

takes the audio file from \Demo\build\classes when executed in runtime and uses any subfolders you care to add such as WaveData.create("audio\\Battle.wav") on top of that location which I dont have a huge issue with.

However in the event you compile the program and run the .jar through command prompt linking the libraries properly the command prompt says null pointer exception as it cant find the audio file placed in the distributions location.

...\NetBeansProjects\Demo\dist-windows-amd64

I have tried placing the audio file in a location and using an absolute refrence too.

WaveData waveFile = WaveData.create("C:\\audio\\Battle.wav");

I even tried

...\NetBeansProjects\Demo\dist-windows-amd64\Demo\build\classes

Yet I get absolutely no compliance what is the standard lookup location because it isnt lib or audio or the same directory as the .jar and for some reason an absolute address just returns null. All I can think of is that theres a bug in the method or you have to use a sub address thats specific to use this method which although makes little sense would explain the issue, does anyone know of such a standard sub address or have a solution that doesnt involve bypassing using a String? I dont want to learn how to apply filestreams to this method at this time if it can be avoided with a simple explanation. Is the method just broken?

p.s. I am running Windows 7 64 bit just incase thats relevant.

Thanks
  EnlightenedOne
« Last Edit: March 08, 2010, 12:37:32 by EnlightenedOne »

*

Offline Matzon

  • *****
  • 2242
Re: Another WaveData.create() issue.
« Reply #1 on: March 08, 2010, 12:53:13 »
classpath

Re: Another WaveData.create() issue.
« Reply #2 on: March 08, 2010, 12:56:59 »
that explains the address of folder it wants (compiled location)\\classpath(place resources in here) but why doesnt an absolute address work or does it look in c:\audio\classpath for the file?

*

Offline Matzon

  • *****
  • 2242
Re: Another WaveData.create() issue.
« Reply #3 on: March 08, 2010, 13:08:37 »
99.9% of the time you never want absolute filesystem paths. Therefore no logic has been added to that case.

If you need this, consider using another create method that takes an inputstream and pass in a new FileInputStream with a File pointing to an absolute path.

Re: Another WaveData.create() issue.
« Reply #4 on: March 08, 2010, 13:31:48 »
No absolute paths are only a good idea on embedded hardware imo, so from where I run the jar file it will be looking for a classpath folder in the folder its run from by defualt, cool. My install of all the jar files had no java docs included so sorry if im talking about something obvious here.

Many Thanks
   EnlightenedOne

Re: Another WaveData.create() issue.
« Reply #5 on: March 08, 2010, 14:51:58 »
What is classpath? I have tried using it as an address from the jar files location.

Demo\dist-windows-amd64\classpath
Demo\dist-windows-amd64\lib\classpath

and changing the look in address too..

WaveData waveFile = WaveData.create("classpath\\Battle.wav");

With no love.

What is the correct syntax for building a statement where by the file in the same directory or a sub directory of the jars location is accessed. I have tried using system codes to get the current file location but it doesn't matter because the address I give to create as a string is not the address its looks at to find the file. Can you be any more specific than saying classpath? I have no idea what context or functional use that your refering too. Can I by any means iscolate where the program is actually looking for the file because that would make things hundreds of times easier than having it return null netbeans debug doesnt show the looking at location because ive checked the strings its being thrown and they are fine.

Sorry if I am missing the obvious thanks
   EO

*

Offline Matzon

  • *****
  • 2242
Re: Another WaveData.create() issue.
« Reply #6 on: March 08, 2010, 15:02:48 »
I think that current path is on classpath, but consider using the path "/path/to/resource/perhaps/in/jar" - or add current dir to classpath by using java -cp .

Re: Another WaveData.create() issue.
« Reply #7 on: March 08, 2010, 15:14:09 »
My bat was setting the PATH to the library so that library files could be found but I tried adding audio and all sorts to there without any luck earlier.

My bat file looks like this.

SET PATH=%PATH%;.\lib (this gets the current jars location and links all the libraries under lib to it there are alot of those)
set
//java -cp .\media (I added this line off of what you just said with no luck)
java -jar Demo.jar (launches the program)

What am I doing wrong here?

Thanks

  EO

Re: Another WaveData.create() issue.
« Reply #8 on: March 08, 2010, 16:41:37 »
I gave up and used a file input stream and a byte value to put the data into the datawave in the end and it works a treat.

Thanks you for trying to help tho  :)
  EnlightenedOne