Introduction

The inotify-java library provides bindings and an API for monitoring the filesystem on Linux platforms. The library uses the inotify interface provided by glibc (versions 2.4 and up) and the Linux kernel (from 2.6.13 on).

Resources

  1. Launchpad project: http://launchpad.net/inotify-java

  2. Bugs: https://bugs.launchpad.net/inotify-java

  3. Asking Questions: https://answers.launchpad.net/inotify-java

  4. YourKit is kindly supporting open source projects with its full-featured Java Profiler. YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products:

Documentation

Tutorials

fsmon

FSMon is a small application written to demonstrate use of the inotify-java library. It uses the com.den_4.inotify.Inotify class to monitor paths and events specified on the command line by the user.

Demo

For example, here /home/nick/.bashrc is being monitored for all events. Any event on this file will be displayed in bold green.

fsmon_run.png

Running the file command over .bashrc will result in the events shown above.

fsmon_trigger.png

Explanation

How it works is exceedingly simple.

An instance of the Inotify class is first created.

creation.png

The addWatch method is invoked for the paths specified by the user. A listener is also setup here for this path.

add_watch.png

Finally, the implementation of the listener method dumps the events and path names to stdout.

listening.png

Resources

inotify-java (last edited 2010-07-08 01:41:05 by nick)