Tuesday, July 11, 2006

Java-Readline on Mac OS X Howto

EDIT: I have updated these instructions so that you can build using the already-installed readline libs that come with OS X (at least Tiger). See the new instructions here.

I have been trying to get java-readline compiled on mac os, and there were references to a blog entry on it, but the entry is now gone.  I found it on archive.org, and here are the instructions I used to get it running:

Using darwinports, do: port install readline

In the source root, edit Makefile and make the following changes:
  • Add JAVA_HOME = /Library/Java/Home below the line # Operating system dependent
  • Make the JAVANATINC variable read $(JAVA_HOME)/include
  • Change LD_LIBRARY_PATH to be DYLD_LIBRARY_PATH

Now, edit src/native/Makefile and change the following:
  • Add -I/opt/local/include to the end of the INCLUDES variable.
  • Change the LIBPATH variable to be -L/opt/local/lib
  • Change the CFLAGS variable to -fno-common
  • Change $(CC) -shared $(OBJECTS) $(LIBPATH) $($(TG)_LIBS) -o $@ to $(CC) -bundle -flat_namespace $(OBJECTS) $(LIBPATH) $($(TG)_LIBS) -o $@

You should now be able to run make and get libJavaReadline.so and libreadline-java.jar. You'll need to rename libJavaReadline.so to libJavaReadline.jnilib.

I put both of these in /Library/Java/Extensions, which makes the library available to all Java processes that are started as you. Make sure everything works by running java test.ReadlineTest from the command line.

0 comments: