(e-mail address removed) wrote:
[about the path of the main class or jar file of an app]
I need this as a location for storing default config file for the
application. I also offer -D option etc..., but I would like anyway to
search for the configuration file inside of the main class directory.
There are several things to keep in mind here:
1) Use the config file only read-only as your app might
be installed by an admin and a user it will not
be able to write to the file.
2) When guessing a directory from a file name, keep
in mind that it may be a (soft) link, which means your
app is actually installed in a completely different place.
3) When you deliver an default config in your jar
file, then just use java.lang.ClassLoader getResourceAsStream().
I would expect this to work even if the jar is unpacked
and the config file changed in place by an admin during
installation.
Harald.