0

I have created an application (You can find the entire thing here to see the problem yourself: https://github.com/Tressos-Aristomenis/Snakes-And-Ladders-JavaFX-from-scratch !) and I have put some background music.

I am actually using a folder called "music" that contains all the tracks. In my pc "music" 's location is at: D:\MyWork\PersonalStuff\Programming\Refactored_SnakesAndLadders_v2\Refactored_SnakesAndLadders_v2\src\music.

If I use this path in my PC to specify where the tracks are, it is working fine. Obviously this is not common to any other PC. I found that "System.getProperty("user.dir")" specifies the location of where the java was run from.

Using the path: private final String TRACKS_PATH = System.getProperty("user.dir") + "\\music"; actually works at my PC as well in a more dynamically way. Now the "music" folder can be found no matter where the project is.

PROBLEM:

Some friends of mine have downloaded the .jar file, even the entire code + the jar and the application is not running; which means there is an NullPointerException at lines:

TRACKS_DIRECTORY = new File(TRACKS_PATH);
TRACKLIST = TRACKS_DIRECTORY.listFiles();

TRACKLIST is an array of files. Obviously TRACKS_DIRECTORY is null cause the path is incorrect.

Any help on how to determine a common path for every user that runs my application?

A.Tressos
  • 35
  • 7

0 Answers0