Environment setup

How to configure TotalCross to run in any IDE and run your first Hello World application

In the next steps of this getting started you will learn how to configure TotalCross and deploy a HelloWorld application to any device on either VSCode, Eclipse, or IntelliJ IDE. Choose the steps you are most comfortable with and get ready to start!

You can create your TotalCross applications from any IDE that supports Java and Maven projects, but we highly recommend starting with Visual Studio Code, using the official TotalCross VSCode plugin, as it is a very quick and easy process.

Visual Studio Code
Eclipse
IntelliJ
Visual Studio Code

Please make sure that your Visual Studio Code is updated, as some issues with the plugin may occur on older versions

Install the TotalCross plugin

Step 1: Open Visual Studio Code and go to Extensions.

Finding the Extensions panel on Visual Studio Code

Step 2: Type TotalCross in the search bar and click to install.

Installing the TotalCross plugin

Create a Hello World project

Step 1: Open VSCode Command Palette (CTRL + Shift + P on Windows, ⇧⌘P on Mac), type TotalCross and select TotalCross: Create new Project.

Creating a new project

Step 2: Create a folder called HelloWorld and select it.

Step 3: Fill in the prompted questions. GroupId is the domain of your company domain backward as in org.wikipedia for wikipedia.org. Feel free to leave it as com.totalcross for this tutorial if you wish.

Setting up a new project

Step 4: ArtifactId is the name of your application, for this example type HelloWorld. Select the latest version of TotalCross SDK and choose whatever platform you intend to deploy your application.

Configuring a new project

Step 5: A new window will open with your project. Right click the RunHelloWorldApplication.java file inside src > main > com > totalcross and choose Run. The TotalCross simulator will open with your brand new application.

Package your application

Step 1: Open VSCode Command Palette (CTRL+Shift+P on Windows, ⇧⌘P on Mac) and search for TotalCross: Package.

Step 2: When the packaging process is finished the target program will take place inside the folder target/install/<platform>.

Deploy and Run you application

Deployment is currently working only for linux arm programs. This feature performs the implementation and execution of the platform via ssh.

Step 1: Open VSCode Command Palette (CTRL + Shift + P on Windows, ⇧⌘P on Mac) and search for TotalCross: Deploy&Run. If you just want to deploy, choose the option TotalCross: Deploy.

Step 2: Fill in the device information.

Step 3: See the result on a display connected to your device or with a VNC client.

Eclipse

Please make sure that your Eclipse IDE for Java Developers is updated

Clone the HelloWorld repository

Step 1: Clone or download this repository containing a TotalCross HelloWorld application

Import and run the project from Eclipse IDE

Step 1: Open the Eclipse IDE and select File > Import...

Step 2: At the import menu, select Maven > Existing Maven Projects

Step 3: Click on Browse... and then select the folder where your HelloWorld repository is located

Step 4: Make sure Eclipse has recognized the pom.xml file and then click Finish

Don't worry if Eclipse shows an error about not finding marketplace entries to handle totalcross-maven-plugin, it won't have any impact in your project. But if you want to get rid of it, follow the instructions at the readme file from HelloWorld project to update your pom.xml and fix the problem.

Step 5: Expand src/main/java at the Package Explorer tab, then expand com.totalcross, right-click the RunHelloWordApplication.java and choose Run As > 1. Java Application. The TotalCross simulator will open with your brand new application.

Package your application

Step 1: Right-click the pom.xml file and chooseRun As > 2. Maven Build...

Step 2: At the Goals text field, type in clean package, and then hit Run

Step 3: Maven will resolve all the dependencies that you need and build your application for the platforms configured at the pom.xml file. This project is configured by default to build to Android, Linux (x86), and Linux_arm targets. Fell free to remove platforms you don't want and maybe add others such as iOS or Windows. The generated folders will be located inside your repository at target/install/<platform>. You can deploy a folder of any platform directly to your target and run your application anywhere!

IntelliJ

Please make sure that your IntelliJ IDE is updated

Clone the HelloWorld repository

Step 1: Clone or download this repository containing a TotalCross HelloWorld application

Import and run the project from IntelliJ IDE

Step 1: Open the IntelliJ IDE. From the starting page, select Open or Import and open the folder where your HelloWorld repository is located. Open it as a maven project.

Step 2: To run your application at the TotalCross simulator, expand HelloWorld/src/main/java at the Project tab, then expand com.totalcross, right-click the RunHelloWordApplication file and choose Run 'RunHelloApplication.main()'. The TotalCross simulator will open with your brand new application.

Package your application

Step 1: Open IntelliJ's maven extension, right-click the option Lifecycle > package and choose Run Maven Build

Step 2: Maven will resolve all the dependencies that you need and build you application for the platforms configured at the pom.xml file. This project is configured by default to build to Android, Linux (x86), and Linux_arm targets. Fell free to remove platforms you don't want and maybe add others such as iOS or Windows. The generated folders will be located inside your repository at target/install/<platform>. You can deploy a folder of any platform directly to your target and run you application anywhere!

Now that your environment is ready, let's create the first embedded project in the next session: