1. Introduction

Create your first project is not complicated, the project provides a Template project using Gradle but you could create a new project from Scratch too.

The advantages of the usage of the Template project are:

  • Build System configured

  • Dependencies defined

  • Tasks defined for the interaction with the Brick

2. Create your first project using the Gradle template project

The project provide a Gradle template project ready to run in your favourite Java IDE like IntelliJ or Eclipse.

Visit this Git repository to download the template project:

git clone https://github.com/ev3dev-lang-java/template_project_gradle.git

Once you have downloaded the project in your personal computer, open the project with your Java IDE to edit the file: config.gradle: to update IP of you Brick:

remotes {
    ev3dev {
        host = ''
        user = 'robot'
        password = 'maker'

to check that the java IDE connect with the brick, execute the following Gradle task:

./gradlew testConnection

The project are configured to send to the Brick the following example:

package examples;

import ev3dev.actuators.lego.motors.EV3LargeRegulatedMotor;
import ev3dev.sensors.Battery;
import lejos.hardware.port.MotorPort;
import lejos.utility.Delay;

public class MyFirstRobot {

    public static void main(final String[] args){

        System.out.println("Creating Motor A & B");
        final EV3LargeRegulatedMotor motorLeft = new EV3LargeRegulatedMotor(MotorPort.A);
        final EV3LargeRegulatedMotor motorRight = new EV3LargeRegulatedMotor(MotorPort.B);

        //To Stop the motor in case of pkill java for example
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            public void run() {
                System.out.println("Emergency Stop");

        System.out.println("Defining the Stop mode");

        System.out.println("Defining motor speed");
        final int motorSpeed = 200;

        System.out.println("Go Forward with the motors");


        System.out.println("Stop motors");

        System.out.println("Go Backward with the motors");


        System.out.println("Stop motors");

        System.out.println("Checking Battery");
        System.out.println("Votage: " + Battery.getInstance().getVoltage());


The example was designed to move a mobile robot with 2 motors connected to Port A & Port B.

2.1. Deploy your program

To deploy the example on your brick, open a terminal and type:

./gradlew deployAndRun

3. Create your first project from scratch

Another alternative is the creation of a project from Scratch using Maven/Gradle.

To start a new project with this library, add the following repository and dependency.


Further information about the dependency

4. Playing with more examples

The project has a repository with several examples about the usage of the different libraries.

Visit the repository about examples to download and test more examples.