This post originated from an RSS feed registered with Java Buzz
by Brian McCallister.
Original Post: POSIX from Java
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
I have been doing more traditionally unix-y stuff from Java lately, and one of the things I have needed is proper access to POSIX and libc system calls. Luckily, there are now a couple fabulous libraries to make this easy – no more need to do your own JNI muckery.
I’ve been using jnr-posix with great success. Using it for something like execv(3) looks like:
The bulk of that snippet is setting up the POSIXHandler which provides nice callbacks for the things that are not obvious how to handle, or might want to be overidden in a specific environment. The boolean flag at the end says to use the native POSIX implementation rather than emulating it in Java. The library will sniff your system and dynamically link the right things – is very nice.
The library doesn’t properly declare its dependencies in its pom, so if you want to use it you need to depend on each of: