Simple Application


Before trying this example, make sure you have the MMM CLI (Command Line Interface) installed.

This example shows the minimal code for a MicroEJ JavaScript application:

  • init the JavaScript code in your Java application with:
import com.microej.js.JsCode;



The class com.microej.js.JsCode is the Java class generated from the JavaScript sources.

  • ask the MicroEJ JavaScript engine to start processing the job queue with:
import com.microej.js.JsRuntime;


This makes the JavaScript engine process the job queue forever until the program is stopped.

  • create a file with the js extension in the src/main/js folder (for example app.js) with the following content:
print("My Simple Application");
  • build and execute the application with the MMM CLI:
$ mmm build
$ mmm run

The message My Simple Application should be displayed.