An API for the leJOS platform intended for introductory Java instruction


Along with colleagues Janet Linington and Matt Jadud in the Computer Science Department of the University of Kent, I have been investigating use of LEGO MINDSTORMS kits as a means to promote an interest in Computer Science among school and University students.

Since 2004, the University of Kent has hosted the Kent Regional Final of the FIRST LEGO League as part of our schools liaison activities.

For schools work, I tend to use ROBOLAB, but I also have a particular interest in use of Mindstorms kits with the Java programming language, for which the excellent leJOS environment is the perfect choice. The leJOS project is an open-source project to provide replacement firmware for the RCX processor of the MINDSTORMS kits. Despite the severe memory limitations of the RCX, leJOS provides an almost complete Java bytecode virtual machine.

In support of my particular aims I have developed an alternative to part of the standard leJOS API that I feel better fits the objects-early approach I take to my teaching.

Using leJOS for introductory Java instruction

I have reworked the existing leJOS API to fit better with the objects-early approach I take in my teaching. My ukcrobots API emphasises device construction and typed sensors slightly more than the original. In addition, this offers two versions of the sensor classes: one set to which listeners may be attached (ukcrobots.core) and a more lightweight version without listener capability (ukcrobots.simplecore).

Students programming models with the ukcrobots API
students using LEGO students using LEGO students using LEGO students using LEGO students using LEGO

Below are a couple of examples to illustrate how models may be programmed using this API:

Occasionally I am asked for the source of my API so I am making it available here in gzipped tar format and zip format. I would be pleased to hear from anyone who finds this useful.

Programming Exercises

At the 34th ACM SIGCSE Technical Symposium on Computer Science Education, 2003, I participated with Pamela Lawhead, Constance Bland, Michaele Duncan, Michael Goldweber, and Madeleine Schep in a special topics session on LEGOS, Java, Programming Assignments and CS 1. There I presented an assignment idea for programming using arrays.

I am in the process of documenting some further programming exercises based around use of the ukcrobots API.

Further reading

The work described here has no official connection with the LEGO company.

LEGO is a registered trademark of the LEGO company.

RCX and MINDSTORMS are trademarks of the LEGO company.

Java is a trademark of Sun Microsystems, Inc.

This document ( is maintained by: David Barnes, to whom any comments and corrections should be addressed.
© David J. Barnes
Last Updated: 17th July 2007
Created: 21st August 2001