I have a Java service that installs a DB on the initial run. I need to set the startup directory for the service to the application directory. Everything I have tried seems to have no effect; each attempt and the working directory is still the \windows\system32.
I'm sure there has to be a way to set the working directory to the application directory and I am just missing it. Some help on this would be appreciated.
I did read a post stating that, in this type of case, you should set the directory using the user.dir property. However this is still not adequate on Windows based machines due to how absolute pathnames are resolved. They are resolved against the current directory of the current drive first, then if that is not set the pathname is resolved against the user.dir setting. Because of this resulting ambiguity on intent when installing a service, the actual working directory should be able to be forced through the installer. Otherwise setting the user.dir will not change how relative pathnames are resolved for the service.
The information on path resolution can be found in the javadocs for File method getAbsolutePath().
The work around is to use user.dir to "fix" the relative to an absolute path. However, that kind of destroys the whole concept of relative paths.
FOLLOW US
Get the latest news in Application Packaging