Domanda

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. My workspace

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.

È stato utile?

Soluzione 2

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.

Altri suggerimenti

Check the current execution dir: new java.io.File(".").getAbsolutePath() will tell you.

Try giving the absolute path of the file and see if that works.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top