Saturday, January 10, 2026

Armed Bear Common Lisp Quick Start

#Introduction

This is a quick run through of how to get coding on the JVM as soon as possible, once everything else has been put in place. My personal style preference is to use the JSS contribution. I will not be covering installation or tools setup, as those have been greatly covered and done better than I could ever bring across.

#Pre-requisites

  • Java / JDK already installed (link to installation).
  • ABCL already installed (link to installation).
  • (Optional) Quicklisp.
  • Minimum Java knowledge required - any freely available tutorial to get up to speed.
  • Minimum to intermediate Common Lisp knowledge.
## My Setup

  This was tested with:
  • ABCL v1.5.0
  • Java 8 v1.8.0_162


#Coding

For this example, we will be calculating the Greatest Common Divisor (GCD) of two numbers. The interface will be simple, using two input dialogs to collect the data and one message dialog for the calculated output. All of this will be done in ABCL, however, I will be using a Java counterpart as well, for testing against - as well as to show that once completed, your clients/end-users will be unable to tell the difference. Since this is a simple application, everything will be in one file. The end product will look like this:

Fig1. asking for the first number
Fig2. Asking for the second number
Fig3. Result of the GCD calculation

##Testing


Before starting, we need to ensure that your Java environment is setup, so quickly run these commands at your console:

```
$ java -version
$ javac -version
```

Now for the Common Lisp (CL) side:

```
$ java -jar /path/to/abcl.jar    # Starts the ABCL REPL
CL-USER> (require :abcl-contrib) ; loads the ABCL Contributions
CL-USER> (require :jss)     ; loads the JSS contribution package
CL-USER> (in-package :jss)
JSS>  (let ((event (#"showMessageDialog" 'JOptionPane (new 'JFrame) "you clicked it"))) event)
```

That last line will display a Message 'you clicked it' as shown in Fig 4. Clicking the 'OK' will return you to the REPL.

##Coding

Now that the environment is buzzing along, let's create the application.


#Honourable Mentions


No comments:

Post a Comment