RFE #26230




Windows 2000 and up. ReadDirectoryChangesW


Solaris 11 and up.


INotify supported in modern kernels. May need to increase fs.inotify.max_user_watches in /etc/sysctl.conf if /proc/sys/fs/inotify/max_user_watches reports it as too low (default is 8192 on Ubuntu).



Mac OS X


(KQueue also possible; some notes:

The KQueue is not suitable for listening on large number of folders as they require file handle to be opened at least in O_EVTONLY. The KQueues are not recursive, even the change of file content has to be monitored by listening on the file not on the folder containing it.

Mac C projects doing FS listening using BSD kernel queues and FSEventStream File:MacFSListening.tgz

I've tested the implementation of the FileMonitor using kqueues ( To be able to listen on file changes in the folder it listens also on all files inside the folder (it holds file handle to all these files). For a sample project (lucene core sources copied into single folder) there are 722 opened file handles (lsof).


NetBeans Platform

Now implemented directly in NetBeans Platform (API in org.openide.filesystems, implementation in org.netbeans.modules.masterfs) since 7.0; uses JNA on Windows, Mac OS X, Linux (inotify), Solaris (FAM); works on JDK 6 or 7.

JSR 203

Linux, Windows, Solaris.

No Mac implementation yet ( is a clue); have not yet checked JDK 7 Preview.

Supports listening to a full hierarchy where supported by the OS (implemented on Windows), using com.sun.nio.file.ExtendedWatchEventModifier.FILE_TREE. For systems which do not support this natively (Linux), it is straightforward to emulate this at the cost of more watches; this is one of the API usage samples.

Backporting to JDK 6 would have many other advantages (richer API for communication with filesystem); cannot use java.** namespace in that case.


Linux, Mac, Windows. Apache. Uses a separate process (communicates using stdio with main process).


Seems to have some impl for Windows already. Proposals for Linux impl and Mac impl


Linux, Mac, Windows. Apache. Semi-active.


Linux, Windows. GPL. Inactive.

Demo in JNA

Just shows that JNA can be used to implement this class of API. Demo implementation only supports Windows.

File:FileSystemWatcher.tgz Implementation of native file system events using JNA based on FSEventStream (Mac OS X 10.5+)




Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo