Thank you for download our SDK!

Getting Started

Introduction to TotalCross

TotalCross has several components including a Java based library that helps you create apps for iOS, Android, Windows, Linux and more.

You will write your code once in Java and TotalCross will generate an executable file for each supported platform.

Creating a Hello World application

1. Running on Eclipse


Creating the Project

After everything is installed, open eclipse, and follow these steps:

  1. File menu, New -> Java Project
  2. Project name: HelloTC
  3. Check "Create separate folders for sources and class files"
  4. Write down the Project location. If you want, change it accordingly
  5. Click Next
  6. Click the Libraries tab
  7. Add External Jars
  8. Add file tc.jar located in the dist folder of the TotalCross installation directory
  9. After the file is added,
  10. Click on the arrow to expand the jar properties
  11. Double-click Source Attachment
  12. Check External location
  13. Click External Folder
  14. Select the src folder in the TotalCross installation directory
  15. Click ok
  16. Click Finish

Creating the Sources

Now we will create the source file and add some code to it.

  1. On the package explorer, right click src folder and type: new / Class
  2. Package: hello
  3. Name: HelloTC
  4. Finish

Now you have to copy and paste the sources below into the Then save it.

package hello;

import totalcross.sys.Settings;
import totalcross.ui.Bar;
import totalcross.ui.Button;
import totalcross.ui.Label;
import totalcross.ui.MainWindow;
import totalcross.ui.dialog.MessageBox;
import totalcross.ui.event.ControlEvent;
import totalcross.ui.event.Event;
import totalcross.ui.font.Font;
import totalcross.ui.gfx.Color;

 * Simple example to help you create your own app with TotalCross.
 * Feel free to modify this code.
 * If you need more help, reach us at
 * You can find the full explanation of this sample at
public class HelloTC extends MainWindow {
    private Label lbl;
    private Button btnHello;
    private Bar barTC;

    public HelloTC() throws Throwable{
         super("", BORDER_LOWERED);
         Font f = Font.getFont(true,Font.NORMAL_SIZE+4);
         barTC = new Bar("TotalCross Ensina");
         barTC.canSelectTitle = true;
         setBackForeColors(Color.getRGB(240, 240, 240), Color.getRGB(50, 50, 50));
         Settings.uiAdjustmentsBasedOnFontHeight = true;

    // Initialize the user interface
    public void initUI() {
         add(lbl = new Label("TotalCross Ensina"), CENTER+20, TOP+650, PARENTSIZE+63, PARENTSIZE+22);
         add(btnHello = new Button("Hello"), CENTER, CENTER+10, PARENTSIZE+38, PARENTSIZE+8);

    public void onEvent(Event e) {
         if(e.type == ControlEvent.PRESSED && == btnHello){
             MessageBox mp = new MessageBox("TotalCross Ensina\n", "Hellow World!");

Running on Eclipse

Now we will run the sample as a Java application.

  1. on Main tab:
  2. Click menu Run / Run configurations
  3. Right click Java Application / New
  4. Name: HelloTC on Android
  5. Project: HelloTC
  6. Main class: totalcross.Launcher
  1. on Arguments tab:
  2. Program arguments: /scr android /r {put your key here} tc.sample.HelloTC
  3. Note: you must pass the key you received by email when you subscribed or you will get an error message.
  4. Click Run

When you run the program, some messages are sent to the console. If you purchased the professional version, a message like "Next SDK expiration date:" will appear. This message shows the due date that you can run and deploy applications without an internet connection before the SDK blocks. You have Always 1 week to do that. If it succeeds, the activation is done only once per day and is pretty fast.

It also shows some key emulations, which are very helpful:

  • F6 : MENU
  • F7 : BACK (ESCAPE)

For example, press the F9 key when you run the sample to simulate the screen rotation.

We can also run as an iPhone with retina display, just changing some parameters.

  1. Run / Run configurations
  2. Right click "HelloTC on Android" and select Duplicate
  3. Name: HelloTC on iPhone
  4. on Arguments tab:
  5. Program arguments: /scr 1920x1080x24 /fontsize 40 /scale 0.25 /r {put your key here} hello.HelloTC

When you run it in the device, TotalCross will automatically set the font size based on the device's user interface. You can easily find these by running the TotalCrossAPI sample on your device and click on the I button at top right. In this sample we use /scale to scale down (or up) so we can see the user interface.

2. Deploying the Application

There are several ways to deploy the application so you can install on a real device. You can use a Linux shell, an ANT script (there’s a sample in the TotalCross Companion), and as a Java application in Eclipse. We will use the last one.

  1. Click Run / Run Configurations
  2. Right-click Java Application, New
  3. Name: HelloTC deploy
  4. Main tab:
  5. Main class: tc.Deploy

Arguments tab:

  1. Program arguments: hello/HelloTC.class /r {put your key here} -all
  2. Working directory: Other
  3. Click Workspace, select HelloTC / bin (or classes) folder
  1. Click Run

It will generate installs folder with all platforms, except for iOS, because it requires a key from the Apple Developer Program. Please refer to the "TotalCross Companion" to see the other deployment options.


How to create a Sample Login Interface

Useful links:

GitHub  |  Blog


How to Deploy

Useful links:

GitLab  |  GitLab


Useful links: