0

I'm programming using IntelliJ IDEA. I'm programming a game. This game needs to save its data inside some files (for example player data, world map exploration data etc.). The problem arises when I want to separate my development environment from the exported .jar executable. When referring to a file in my project, I use a path like "saves/world1/players/player1.data". This file is accessible by using File("saves/world1/players/player1.data"). However, the more files I need, the more my project gets cluttered, because all the files are added into my project root directory. Also, when exporting the .jar artifact, it only exports the .jar file and I have to copy all the other files manually into the same directory as the .jar file. How do I automate this process and how do I organize the files a little better (like putting them in one directory to not clutter my project root folder)? Also, I should mention that I use Kotlin, but I don't this it's important for this question. A Java solution might work just as well.

Dj Sushi
  • 313
  • 2
  • 14

1 Answers1

0

Have you application declare a file path property from where you load these large external data files. For local dev/testing this can default to a path local to your project but for deployment you'd perhaps have start or execution scripts which allow the user to configure where there '.data' file located.

emeraldjava
  • 10,894
  • 26
  • 97
  • 170
  • Thank you. Do you have any specific examples/resources? I tried searching for 'start script' and 'execution script' with no luck. – Dj Sushi Mar 29 '22 at 22:06
  • See https://stackoverflow.com/questions/7351533/set-multiple-system-properties-java-command-line – emeraldjava Mar 30 '22 at 20:00