Skip to main content

Build and run the Hello World dapp with Eclipse IDE

In this topic, you'll build and deploy the Hello World dapp with the Rell plugin for Eclipse.

Prerequisites

Hello World in Rell

Once you install the Rell plugin for Eclipse, it's time to create a project.

  1. Switch to the Rell perspective. Menu: Window - Perspective - Open Perspective - Other, choose Rell.

  2. Create a project:

    • Menu File - New - Rell Project.
    • Enter a project name test and click Finish.

    You get a new Rell structured project with the necessary files.

  3. Open the module.rell file:

    • Click on the project folder test folder and then src - test.
    • Click on the module.rell file to open the editor.
  4. Write the following code in the editor and save the file.

        function main() {
print('Hello, World!');
}
  1. Run the program: right-click the editor and select Run As - Rell Console App.

    Your console should show you the following message.

    "Hello World!"

Eclipse IDE overview

Eclipse IDE window consists of different views. Every view has its own tab. By default, Rell IDE has the following views:

  • Project Explorer - shows projects and their directory trees.
  • Problems - shows compilation warnings and errors.
  • Console - console output (when running programs).
  • Outline - shows the structure of a selected Rell file.

Running applications

Right-click a file (or an editor) and choose Run As. You see the run options for the file.

Rell console app

Rell console app executes a *.rell file as a stand-alone console program, not as a module in a Postchain node.

The program must contain a function (or operation, or query) called main, which is the entry point. You see the output in the Console view.

You can specify the name of the main function and its arguments in run configuration.

Database connection

By default, the program runs without a database connection, and an attempt to perform a database operation results in a run-time error.

To run a console app with a database connection, there should be a file called console-db.properties, db.properties or node-config.properties in the directory of the Rell file or the rell/config directory of the project. The file must contain database connection settings. For example:

database.driverclass=org.postgresql.Driver
database.url=jdbc:postgresql://localhost/postchain
database.username=postchain
database.password=postchain
database.schema=rell_app

When running a console app with a database connection, tables for defined classes and objects are created at the start-up. If a table already exists, missing columns are added, if necessary.

To prepare a database, see Set up PostgreSQL database.

Rell postchain app

Starts a Postchain node with a configuration written in the Run.XML format. To use this option, right-click a *.xml file, not a *.rell file.

You can use run.xml to run multiple blockchains in one Postchain node.

Example of a minimal run.xml:

<run>
<nodes>
<config src="node-config.properties" add-signers="true" />
<test-config src="node-config-test.properties"/>
</nodes>
<chains>
<chain name="test" iid="1">
<config height="0">
<app module="test">
</app>
</config>
</chain>
</chains>
</run>

Wipe database

This option is available for database properties files, *.properties (for instance, node-config.properties). It drops all tables (and stored procedures) in the database.

Run with a keyboard

By default, CTRL-F11 (⇧⌘F11) shortcut runs the file of the active editor. You can configure it to run the last launched app instead, which may be more convenient as there is no need to choose an app type. Go to the menu Window - Preferences (macOS: Eclipse - Preferences), then Run/Debug - Launching. In the Launch Operation box, select Always launch the previously launched application.

Running multiple apps

It's possible to run multiple apps (multiple nodes) simultaneously. For example, one can define two Run.XML configuration files that use the same Rell module but different ports and database schemas.

You can see the output of all running apps in the Console view but on different pages. Switching between the consoles of different applications is possible using a button or a dropdown list.

Run configurations

Eclipse IDE needs a run configuration to run an app, which contains different properties, like the name of the function, arguments, or Blockchain RID. When running an app via the Run As context menu, the Eclipse IDE automatically creates a run configuration with default settings if they don't exist.

To change a run configuration, go to the menu Run - Run Configurations. By default, you see the last launched app. Change the settings and click Apply or Run to save the changes.