Posix for Java

by Stuart D. Gathman
Last updated Sep 28, 2009

Why Posix for Java?

A frequently asked question on Java newsgroups is "How do I use unix signals (or messages or environment variables or ...) in Java?" The answer is, you can't with standard Java. Equivalent features are in Java. For example, Properties instead of environment variables or Sockets instead of the various forms of unix IPC.

However, sometimes it is necessary to interface with code written for the unix environment - and that code can't be rewritten to use Sockets. In those cases, it would be nice to have simple access to the Posix API without everyone having to reinvent the wheel.

One solution is the posix package. This package provides access to the posix API from Java. It uses a JNI library which should be portable to other posix systems. I started this package with the intent of making it reusable by others. However, it only has the classes I have needed for my own projects at present :-). I am making the source and docs public so that others can reuse what I have so far and so that I can collect any additions added by others.

There is another posix API for Java used by the Jython project: jnios. I will be looking at incorporating features from that package, or getting rid of my own entirely. I will not get rid of 'posix' if the jnios package requires jython.

Please see the javadocs for further information.

Here is the current source as a directory for your inspection. Send comments to Stuart D. Gathman.

  • The Javadocs.
  • Browse 1.2.2 source online.
  • posix-1.2.2.tar.gz Fix Stat.chmod() return value. AIX 5 port.
  • Browse 1.2.1 source online.
  • posix-1.2.1.tar.gz Add Stat.utime(), Stat.chmod(), Stat,chown(), File.setAccessed(), File.setTimes(), File.setOwner(), File.setMode(). I pulled a switcheroo and added chmod, chown after one download of 1.2.1. Sorry if that causes version confusion.
  • Browse 1.2 source online.
  • posix-1.2.tar.gz Add setPerm() method to IPC classes. Version 1.2 abandons JDK 1.1 compatibility. JDK 1.1 users will have to continue from posix-1.1.9.
  • Browse 1.1.9 source online.
  • posix-1.1.9.tar.gz Support lstat() and S_IS(XXX,mode) in Stat class.
  • posix-1.1.8.tar.gz Fix Passwd parsing empty field. More robust Signal. Export IPC.getID(). Fix Errno with GNU strerror_r().
  • RPM for jdk1.5.0_16
  • RPM for jdk1.5.0_16
  • Source RPM for jdk1.5.0_16