1

I am running my Application from a network-share. For example: "\server\startProgramm.bat" The Code in my startProgramm.bat:

java -jar %~dp0\app.jar

I need to open some config files. It is working local if i try to open them with:

new File("").getAbsolutePath() + "\\" + filename

but not on my Network share.

The config-files are in a subdir of the dir where my jar and bat files are.

jussi
  • 2,166
  • 1
  • 22
  • 37

1 Answers1

0
new File("\\\\servername\\sharedDirectoryOnServer\\fileOnServer");

"Ok, this worked, but is there something like CurrentWorkDir?"

The current working directory is (by default) the one your program runs in. You can not change it within java (see here: Changing the current working directory in Java? ), the best practice is to just concatenate the server-path and file-name; but i think (not sure) it is also possible to start your program from the server (java \\server\\path\\myprog where there's a myprog.class in that directory) and make the working directory default to that path.

Community
  • 1
  • 1
Bernd Elkemann
  • 23,242
  • 4
  • 37
  • 66