This feels like an absolute newbie question, but I'm on a colossal yak-shave over what should be an elementary concern.
I'm writing a simple desktop app in Java. (Scala actually, but let that pass.) It targets Windows machines. I want to package it and have it runnable without creating an installer, or messing about with the Windows registry. And I want a config file that users can find and edit in order to customize settings. (In the manner of SublimeText's user preferences, for example.)
I envision the following structure:
|- myApp.class (or myApp.jar, if you prefer)
File resolves relative paths by default in the user's current working directory (available as system property
user.dir). So, if you do
cd on command line to change to a directory and then invoke the Java application this directory will be the current user's working directory from the point of view of the Java application.
One thing you can do is to pass your base-directory as system property to the Java application. This can be done within a shell script that starts your application by using it's own location.
Another possibility is to include the files like configuration file in classpath when invoking the Java application and to load them from classpath in Java application. The disadvantage of this solution is that the user can do more things than needed with damage as a possible result.