Lesson: How do we use Java?

Explore how Java is used to write, produce and deploy programs.

Understand the basic Java programming process: creating source code, compiling source code and deploying/executing the result.


So how do we produce Java programs? Java is a text  based language, so the first step is to write the source code for our Java application using a text editor and save that source text in a file. You can use any editor you wish.

Next that source file is passed to the Java compiler. The compiler reads the Java source and checks for errors and if no errors are found, outputs the appropriate bytecode to a second file for execution.

Normally the next step is to start the Java Virtual Machine on your system and pass it the file of Java bytecode and the JVM runs your program. In the case of robots, this step is two parts. First you download your program file to some robot computer (called deployment) using tools provided in your robot SDK. Then the JVM on the robot is told to execute your program.

The Java compiler and a JVM are installed on your computer when you install the Java SDK. The JVM for your robot is installed as part of your robot platform SDK or may come pre-installed. Note that your robot SDK may have an SDK for your development PC and one for your robot controller.

In the simple case, you are responsible for selecting a text editor to use and figuring out the steps needed to compile and deploy your program to the robot. This sounds simple but in actual practice can be quite complex, particularly deployment. To simplify program development, tools called Integrated Development Environments (IDE) were created. IDEs have a powerful text editor and perform compiling and deployment with the click of a button. IDEs typically understand your installed APIs and SDks and integrate these tools into your editing workspace. IDEs provide a lot of programming support and take care of lot of the messy details.

For the EV3 the IDE we use is Eclipse, for Tetrix the IDE is Android Studio and for the RoboRio the IDE is Visual Studio Code. These tools will be discussed in more detail later.