Reputation: 41
I am trying to play an mp3 using an external mp3 library and everything is fine until it comes to finding the file.
I have imported the file into eclipse as seen in the below image.
And here is my error:
enProblem playing file mpthreetest.mp3
java.io.FileNotFoundException: mpthreetest.mp3 (The system cannot find the file specified)
java.lang.NullPointerException
Any help would be appreciated.
Upvotes: 0
Views: 660
Reputation: 712
You cannot find your file because you're trying to access it by a relative path. But probably you aren't considering that a package, at runtime, is NOT a directory.
So, if you try to look for a file by new File("myfile") the JVM assume you're starting from the "root" of your application (usually the working dir).
To solve this situation you can put the mp3 file in root package or by referring to it via absolute path.
Upvotes: 0
Reputation: 2332
Try giving the absolute path of the file and see if that works.
Upvotes: 0
Reputation: 1722
Check the current execution dir: new java.io.File(".").getAbsolutePath()
will tell you.
Upvotes: 1