jabotics logo

Interface for console programs

Before dealing with robot programs, it might be helpful for real beginners to introduce the required Java essentials in the context of even simpler examples. One option is to do this by means of console applications based on the package org.jabotics.console.en and the class template templates/en/Console.tmpl (to be found within the Jabotics installation directory). The Java package, its documentation (start page docs/console-en/index.html) and the class template have been designed to anticipate the workflow with robot classes.

The package org.jabotics.console.en provides a single public interface IConsole and its implementation class XConsole supporting the input / output of text and figures via the BlueJ console. The template Console.tmpl has the same structure as the robot class template Robot.tmpl just that it provides only a single control object:

static final XConsole console = new XConsole();

The user will again have to implement the main method which in this case has an unusual signature without any parameters:

public static void main()

In this way console applications based on the template can be started very easily in BlueJ. It will be sufficient to do a right-click on the class symbol in the project view and to select the menu entry void main() without the need to specify any parameters for the method call. Starting the console application in this manner will open the BlueJ console to which all input and output operations will be directed. The template's sample implementation for the main method again demonstrates the usage of the console object and needs to be replaced by the user.