Is there a Java library of Unix functions?

Solution 1:

I'm aware of two compelling projects:

  • posix for Java (based on JNI) [derived from Jython]
  • jna-posix (based on JNA) [derived from JRuby]

Personally I like very much JNA. Take a look at this example of mine, mapping link(2):

import com.sun.jna.Library;
import com.sun.jna.Native;

class Link {

    private static final C c =
        (C) Native.loadLibrary("c", C.class);

    private static interface C extends Library {

        /** see man 2 link */
        public int link(String oldpath, String newpath);
    }

    @Override
    protected void hardLink(String from, String to) {
        c.link(to, from);
    }
}

Solution 2:

JNA-POSIX is stagnant currently, as far as I know.

The developers went on to create JNR-POSIX