Another WaveData.create() issue.

Started by EnlightenedOne, March 08, 2010, 12:35:18

Previous topic - Next topic

EnlightenedOne

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

Matzon


EnlightenedOne

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?

Matzon

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.

EnlightenedOne

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

EnlightenedOne

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

Matzon

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 .

EnlightenedOne

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

EnlightenedOne

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