The project I'm working has been using Java 6 and jpathwatch (.95) and is now upgrading to Java 7. Currently on Windows 7 and 2008 Server. I'm refactoring areas of code to use the new Java 7 NIO and is relatively straight forward - even using the NIO.2 to replace jpathwatch. However, the file watching area of our code began failing unit tests. It seems the Java 7 NIO will not pick up changes in UNC paths to other machines -
\\otherMach\path\to\watch.
To test, I implemented the code from the Java NIO tutorial site http://docs.oracle.com/javase/tutorial/essential/io/fileio.html and then created a duplicate class swapping in the jpathwwatch imports instead of the Java NIO imports. jpathwatch works for the UNC paths but Java NIO does not. It seems to register and even returns an initial event key for the location: (sample output)
INFO: Watching: \\otherMach\path\to\watch
DEBUG: Added: \\otherMach\path\to\watch
INFO: Got event key: sun.nio.fs.WindowsWatchService$WindowsWatchKey@1f26ecd2
INFO: event key for: \\otherMach\path\to\watch
but then never recognizes any further changes.
jpathwatch registers and reports directory and file events (although it doesn't report the initial event right after registering).
INFO: Watching: \\otherMach\path\to\watch
DEBUG: Added: \\otherMach\path\to\watch
INFO: Got event key: name.pachler.nio.file.impl.WindowsPathWatchService$WatchRecord@79a7bd3b
INFO: event key for: \\otherMach\path\to\watch
INFO: EVENT RECEIVED: ENTRY_CREATE file/dir created - \\otherMach\path\to\watch\New folder
INFO: Got event key: name.pachler.nio.file.impl.WindowsPathWatchService$WatchRecord@79a7bd3b
INFO: event key for: \\otherMach\path\to\watch
INFO: EVENT RECEIVED: ENTRY_CREATE file/dir created - \\otherMach\path\to\watch\New Text Document.txt
This is despite seeing on the jpathwatch discussion that networked watching is NOT supported - note response by Uwe Pachler refering to UNC paths - http://sourceforge.net/p/jpathwatch/discussion/888207/thread/8ea778de/?limit=25#0037
Has anyone had any luck with watching UNC paths and Java 7 NIO.2? Any other or more recent solutions?
Thank you,
-mjash