In my last post I shared how to get a working version of leJOS running on your wifi-enabled EV3.  Now we need to make it do something, so in this tutorial I will cover the basic tools for compiling, uploading and executing leJOS Java programs on the EV3.

Get the leJOS source

Andy has uploaded the current working source code for leJOS into a Github repository. The repository lives at You can browse the repository in your web browser to view individual files, but if you want to work with the examples and build new code it is best to use the git command to check out a local copy of the repo:

git clone git:// lejos-ev3


Alternatively you can download a zip file of the current snapshot from Github by clicking on the Download Snapshot link at the top of the frame:

Download snapshot


When you unpack the snapshot tarball, or run the git clone command, you’ll end up with the leJOS EV3 class files and sample programs in a directory named lejos-ev3.

Basic Tools

To compile Java programs for the EV3 you will need…Java! The version that is installed on my Mac is Java 1.6:

$ java -version
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)


The beauty of Java is that it compiles code to bytecode, and that bytecode can run on almost any platform. It is easy to compile your Java code on one platform (a Mac, Linux or Windows box) and then run it on another (the EV3). Download the latest Java JDK for your platform from the Oracle website.

To get data to and from the EV3 you will need an ssh program. The Linux version running on the EV3 runs a copy of the Dropbear ssh server. Dropbear is optimised to run on embedded platforms, but supports all of the standard ssh protocol commands to login into the terminal and copy files. ssh is installed by default on Mac OS and Linux systems. For Windows you will need to download the amazing PuTTY terminal emulator that provides ssh support.

Let’s log into our EV3 and get to a command prompt (doing this for the first time is the most exciting bit!):


There is no password set for root, so just hit enter when prompted for the password at login. As you can see the EV3 is running a Linux ARM build.

Compiling HelloWorld

Let’s turn our attention back to our host PC where we previously downloaded the Github image of the EV3 leJOS source. We will start by compiling the classic HelloWorld program that Andy has provided and then we will upload the resulting class file to the EV3 where we can run it.

Change to the directory lejos-ev3 containing the source code and let’s look at the file:

src $ pwd
src $ cat
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;

import lejos.nxt.LCD;
import lejos.nxt.Button;
import lejos.nxt.Sound;
import lejos.util.Delay;
public class EV3HelloWorld

     * @param args
    public static void main(String[] args)
        final int SW = LCD.SCREEN_WIDTH;
        final int SH = LCD.SCREEN_HEIGHT;
        Graphics g = new Graphics();
        g.drawString("leJOS/EV3", SW/2, SH/2, Graphics.BASELINE|Graphics.HCENTER);




Next we will compile this with Java. The key step here is to provide Java a pointer to the ev3classes.jar file which contain the EV3-specific leJOS code:


As you can see we now have a EV3HelloWorld.class file ready to upload to the EV3.

Uploading to the EV3

To copy our class file onto the EV3 we use the scp command provided by the ssh toolset:

src $ scp EV3HelloWorld.class root@
Coming soon: how to set up an NFS server on your EV3...

Running the Java class file on the EV3

To run the Java file on the EV3 we use the jrun command that Andy has provided:

root@EV3:/lejos/samples# jrun EV3HelloWorld


After a short delay to start the Java interpreter your EV3 should make a series of beeps upwards, display leJOS/EV3 on the screen and then a sequence of beeps downwards. Success!

Stay tuned for more tutorials on programming the EV3 in leJOS…