Java nio cant read UNC

693 views Asked by At

I have a program where I actively ping the contents of a directory using nio.WatchService.

Anytime a new file is added there, I process some custom logic. The path to the folder is read from a properties file and has the following format:

pathvar=C:\\files\\in\\ -->works on local
pathvar=\\\\serv123\\Share\\input\\ --> works on local

Both formats run fine on win 7 local (command line and through IDE). When executed on a win 2008 R2 server, the program executes when path variable is local - no (mapped) network paths work.

pathvar=C:\\\\files\\in\\ -->works
pathvar=\\\\serv123\\Share\\input\\ --> does not work
pathvar=N:\\Share\\input\\ --> N: mapped to serv123 does not work

Code is same as listed here:Watching a Directory for Changes in Java

I don't get any exceptions either, but UNC paths are not working. Any help is appreciated.

Edit: The way I deducted the issue was path related(in absence of any exceptions), is by playing around with the paths.

I packaged it as a jar and run it on the command window as

java -jar myjar.jar

With pathvar=C:\files\in\, the programs runs and waits With pathvar=\\server\files\in\, it quits immediately/

0

There are 0 answers