Directory monitoring on NTFS

Hello all,

I am in a situation where I need to monitor a directory for changes
(Basically only when files are created in it) on Windows (NTFS
filesystem) from a long running jruby script.

After a bit of searching I found however this uses a C
Extension and requires the win32 gem etc.

Since I am going to be using JRuby I thought there must be a java based
solution and it looks like Java 7 got a “WatchService” interface.

This looks good but before I delve into the “J” in JRuby I just wanted
to see if anyone had already faced this question and had any other ideas



I would go with the Java 7 solution over a native C extension. Using
directly from JRuby is usually a smoother path than working with C
extensions, plus if you use the Java solution your code should work on
any platform and wouldn’t be a Windows specific solution in case you
needed something different in the future.


I’m using the Java 7 watch service for a small little app at work and it
really didn’t take too long to get it working. These blog posts summed
what it does pretty simply:

I know that Headius mentioned JNotify some time ago as an option, and if
you don’t want to use Java 7 for it, this is probably another good
that you might be able to:

and with a little bit of googling, someone might have already wrapped it

-Nick K.

Thanks very much all.

Easy to find when you know the correct search terms.