| 1 | <?xml version="1.0"?> |
|---|
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
|---|
| 3 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|---|
| 4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
|---|
| 5 | <head> |
|---|
| 6 | <title>Installing armedbear the Java way</title> |
|---|
| 7 | <base href=""> |
|---|
| 8 | <link rel="stylesheet" |
|---|
| 9 | type="text/css" |
|---|
| 10 | href="abcl-css.css"> |
|---|
| 11 | <link rel="stylesheet" |
|---|
| 12 | type="text/css" |
|---|
| 13 | href="http://common-lisp.net/project/armedbear/style.css"/> |
|---|
| 14 | </head> |
|---|
| 15 | |
|---|
| 16 | <body> |
|---|
| 17 | <a name="top"></a> |
|---|
| 18 | <div class="header"><h1>armedbear</h1></div> |
|---|
| 19 | |
|---|
| 20 | <a href="http://common-lisp.net/project/armedbear/">home</a> |
|---|
| 21 | |
|---|
| 22 | <div id="welcome"> |
|---|
| 23 | <pre> |
|---|
| 24 | C:\temp\abcl\abcl-src-0.12.0\dist>java -jar abcl.jar |
|---|
| 25 | Armed Bear Common Lisp 0.12.0 |
|---|
| 26 | Java 1.6.0_05 Sun Microsystems Inc. |
|---|
| 27 | Java HotSpot(TM) Client VM |
|---|
| 28 | Low-level initialization completed in 1.262 seconds. |
|---|
| 29 | Startup completed in 4.556 seconds. |
|---|
| 30 | Type ":help" for a list of available commands. |
|---|
| 31 | CL-USER(1): (list 'welcome 'to 'lisp!) |
|---|
| 32 | (WELCOME TO LISP!) |
|---|
| 33 | CL-USER(2): |
|---|
| 34 | </pre> |
|---|
| 35 | </div> |
|---|
| 36 | <h1>Integrating Lisp into Java</h1> |
|---|
| 37 | |
|---|
| 38 | <p> |
|---|
| 39 | This page describes you can use ABCL to integrate Lisp into a Java application. |
|---|
| 40 | Why is this useful? Well, you get the best of both worlds -- you get the |
|---|
| 41 | power of Java and can call upon the very large number of existing tools and |
|---|
| 42 | programs that have been implemented in Java, and merge this with the incredible |
|---|
| 43 | poower of Lisp. So if you have a useful Lisp application rather you no longer |
|---|
| 44 | need to rewrite it in Java. Simply call the ABCL Lisp interpreter to execute |
|---|
| 45 | its Lisp code. |
|---|
| 46 | </p> |
|---|
| 47 | |
|---|
| 48 | <h2>How to compile your Java-Lisp code</h2> |
|---|
| 49 | <p> |
|---|
| 50 | Your Java code will use the special classes provided by ABCL to allow it to |
|---|
| 51 | access the methods needed to interact with your Lisp code. This means that the |
|---|
| 52 | ABCL JAR file needs to appear in your CLASSPATH. Depending on how you build |
|---|
| 53 | your application will depend on the method you choose to use. The simplest |
|---|
| 54 | method is to use the <tt>-cp</tt> option to the Java compiler. Alternatively |
|---|
| 55 | you can set the <tt>CLASSPATH</tt> environment variable, thus simplifying the |
|---|
| 56 | Java command line. Finally you may set the CLASSPATH in your IDE, or using the |
|---|
| 57 | Ant <tt><classpath></tt> tag. To make this more concrete consider you |
|---|
| 58 | have a Java file called <tt>myapp.java</tt>. Then if you use the <tt>javac</tt> |
|---|
| 59 | command to run the Java compiler, your command may look like this (we are, of |
|---|
| 60 | course, describing a Windows platform): |
|---|
| 61 | </p> |
|---|
| 62 | <pre> |
|---|
| 63 | javac -cp c:\path\to\abcl.jar myapp.java |
|---|
| 64 | </pre> |
|---|
| 65 | <p> |
|---|
| 66 | Of course if you have other elements in your classpath you will have to make |
|---|
| 67 | the path more complex to take this into account. So, for example, if you have |
|---|
| 68 | other JAR files in <tt>c:\apps\java-libs</tt>, and the JAR file |
|---|
| 69 | <tt>c:\3rd-party-apps\lib\special-tools.jar</tt>, the command will have to be |
|---|
| 70 | modified to look like this: |
|---|
| 71 | </p> |
|---|
| 72 | <pre> |
|---|
| 73 | javac -cp c:\path\to\abcl.jar;c:\apps\java-libs;c:\3rd-party-apps\lib\special-tools.jar myapp.java |
|---|
| 74 | </pre> |
|---|
| 75 | <p> |
|---|
| 76 | It is clear from the above that the command is getting more and more complex. |
|---|
| 77 | As you add more classes to the commmand line so it will grow, and perhaps |
|---|
| 78 | exceed the maximum command line length. The general solution to this is to |
|---|
| 79 | take the class path information out of the command and store it in an |
|---|
| 80 | environment variable called <tt>CLASSPATH</tt>: |
|---|
| 81 | </p> |
|---|
| 82 | <pre> |
|---|
| 83 | set CLASSPATH=c:\path\to\abcl.jar;c:\apps\java-libs;c:\3rd-party-apps\lib\special-tools.jar |
|---|
| 84 | javac myapp.java |
|---|
| 85 | </pre> |
|---|
| 86 | <p> |
|---|
| 87 | </p> |
|---|
| 88 | </body> |
|---|
| 89 | </html> |
|---|