Skip to content
An implementation of Java 7’s WatchService for OS X
Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
.travis-settings.xml
.travis.yml
Demo.asciidoc
README.asciidoc
pom.xml

README.asciidoc

BarbaryWatchService

This is the official BarbaryWatchService repository, moved from https://code.google.com/p/barbarywatchservice/

See issues for current plans.

Build Status

An implementation of Java 7’s WatchService for Java 6 on Mac OS X

Java 7 has an API to detect file system changes called Watch Service. This project uses JNA to hook into Apple’s File System Events API.

This is almost a direct drop-in replacement for Java 7’s Watch Service API. I’ve used the API source code from OpenJDK 7 as much as possible.

There’s a Demo example here.

A lot of source code is from OpenJDK.

Differences from Java 7’s API

You obtain a Watch Service instance as follows:

WatchService watcher = WatchService.newWatchService();

Instead of creating Path objects, use WatchableFile objects:

WatchableFile file1 = new WatchableFile(new File("/path/to/watch"));

There is a tutorial for Java 7’s Watch Service API here.

Download

Get the Maven dependency:

  <dependency>
    <groupId>net.incongru.watchservice</groupId>
    <artifactId>barbary-watchservice</artifactId>
    <version>1.0</version>
  </dependency>
You can’t perform that action at this time.