The project I'm working on uses Java 6 and jpathwatch (.95) and is now upgrading to Java 7. Currently on Windows 7 and 2008 Server. I will reorganize areas of code to use the new Java 7 NIO and relatively straight forward - even using NIO.2 to replace jpathwatch. However, the file browsing area of ββour code began to fail unit tests. It seems that Java 7 NIO will not receive changes in UNC paths to other machines -
\\otherMach\path\to\watch.
To test, I injected the code from the Java NIO training site http://docs.oracle.com/javase/tutorial/essential/io/fileio.html , and then duplicated the class exchange in the jpathwwatch import instead of the Java NIO import, jpathwatch works for UNC paths, but Java NIO does not. It seems to register and even return the 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 does not recognize further changes.
jpathwatch logs and reports the directory and events of the file (although it does not report the start event immediately after registration).
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 the fact that you see in the jpathwatch discussion that network monitoring is NOT supported - pay attention to Uwe Pachler, referring to UNC paths - http://sourceforge.net/p/jpathwatch/discussion/888207/thread/8ea778de/? limit = 25 # 0037
Is anyone lucky with viewing UNC paths and Java 7 NIO.2? Any other or later solutions?
Thanks,
-mjash
java nio nio2 watchservice
mjash
source share