Posted by & filed under Geekery.

I’ve really let someone down. This blog’s been up for all of a week, now, and someone’s already been here looking for java-readline mac os x.

And of course I didn’t have this entry written just yet…

The process isn’t really all that hard, but it is non-obvious. Someone should probably contribute this tidbit back to the source...

I found an initial set of instructions by Ian Cooke (dated September ‘02) that referenced only “OS X”. I find things to be a fair bit simpler with Panther and DarwinPorts than Ian dealt with.

For starters, you’ll need to get DarwinPorts up and running if you haven’t already done so. Once that’s done, just do a port install readline. You should know your DarwinPorts install root once you’ve installed it; in my case it’s /opt/local.

Compilation of java-readline is pretty straightforward at this point, but you do need to patch both Makefiles in the source distribution to account for the non-Linux and non-Win32 options you’ll need for the linker.

These changes apply to java-readline version 0.8.0. 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 -L/usr/lib
  • Change the CFLAGS variable to <del>fno</del>common (that should read “dash fno dash common”; stupid markdown.)
  • Change
    $(CC) -shared $(OBJECTS) $(LIBPATH) $($(TG)_LIBS) -o $@
    to
    $(CC) -bundle -flat_namespace -undefined suppress $(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.

Comments are closed.