armedbear

home
C:\temp\abcl\abcl-src-0.12.0\dist>java -jar abcl.jar
Armed Bear Common Lisp 0.12.0
Java 1.6.0_05 Sun Microsystems Inc.
Java HotSpot(TM) Client VM
Low-level initialization completed in 1.262 seconds.
Startup completed in 4.556 seconds.
Type ":help" for a list of available commands.
CL-USER(1): (list 'welcome 'to 'lisp!)
(WELCOME TO LISP!)
CL-USER(2):

Integrating Lisp into Java

This page describes you can use ABCL to integrate Lisp into a Java application. Why is this useful? Well, you get the best of both worlds -- you get the power of Java and can call upon the very large number of existing tools and programs that have been implemented in Java, and merge this with the incredible poower of Lisp. So if you have a useful Lisp application rather you no longer need to rewrite it in Java. Simply call the ABCL Lisp interpreter to execute its Lisp code.

How to compile your Java-Lisp code

Your Java code will use the special classes provided by ABCL to allow it to access the methods needed to interact with your Lisp code. This means that the ABCL JAR file needs to appear in your CLASSPATH. Depending on how you build your application will depend on the method you choose to use. The simplest method is to use the -cp option to the Java compiler. Alternatively you can set the CLASSPATH environment variable, thus simplifying the Java command line. Finally you may set the CLASSPATH in your IDE, or using the Ant <classpath> tag. To make this more concrete consider you have a Java file called myapp.java. Then if you use the javac command to run the Java compiler, your command may look like this (we are, of course, describing a Windows platform):

javac -cp c:\path\to\abcl.jar myapp.java

Of course if you have other elements in your classpath you will have to make the path more complex to take this into account. So, for example, if you have other JAR files in c:\apps\java-libs, and the JAR file c:\3rd-party-apps\lib\special-tools.jar, the command will have to be modified to look like this:

javac -cp c:\path\to\abcl.jar;c:\apps\java-libs;c:\3rd-party-apps\lib\special-tools.jar myapp.java

It is clear from the above that the command is getting more and more complex. As you add more classes to the commmand line so it will grow, and perhaps exceed the maximum command line length. The general solution to this is to take the class path information out of the command and store it in an environment variable called CLASSPATH:

set CLASSPATH=c:\path\to\abcl.jar;c:\apps\java-libs;c:\3rd-party-apps\lib\special-tools.jar
javac myapp.java