Thank you for download our SDK!

Check your email, you have received your key and the download link.

Getting Started

Introduction to TotalCross

Free SDK
Github SDK:
Rich User Interfaces
Sample Store
Facebook UI Sample

TotalCross is 100% Java compatible library that runs over Java SE, mobile and desktop platforms. It was born in 2001 and works on any Java SE platform using Java’s virtual machine. It also runs as a Java application and applet, on Windows 2000+, Linux, Android 2.3+, iOS 7+, Windows Mobile 5+ and Windows Phone 8.0+; all these platforms use a register-based virtual machine, the TCVM. A few other platforms were supported i n the past, like Palm OS, Blackberry and Symbian.

Creating a Hello World application

1. Running in Eclipse


• Java SDK (not the JRE) -
• Eclipse IDE for Java developers -
• TotalCross SDK (install it at c:\TotalCross3) –


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

• File menu, New -> Java Project
• Project name: HelloTC
• Check “Create separate folders for sources and class files”
• Write down the Project location. If you want, change it accordingly

• Click Next
• Click the Libraries tab
• Add External Jars
• Add file c:\TotalCross3\dist\tc.jar
• After the file is added,
• Click on the arrow to expand the jar properties
• Double-click Source Attachment
• Check External location
• Click External Folder
• Select c:\TotalCross3\src
• Click ok
• Click Finish

You can learn a lot by looking at the sources. Attaching the jar to the source files allows to see the javadocs and also step into the TotalCross library during debugging.


Now we will create the source file and add some code to it.
• On the package explorer, right click src folder and type: new / Class
• Package: tc.sample
• Name: HelloTC
• Finish


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

A few explanations from the sample:

• Every TotalCross application has one and only one class that extends MainWindow.
• TotalCross has some user interface styles that work on all platforms: Flat, Vista and Android.
• The most powerful feature of TotalCross is the user interface. It uses relative positioning, where a control’s position is computed based on another one and the size is usually based on the control’s properties. An adjustment based on the font’s height can be made (+100 = font height, +50 = half font height), except for the PARENTSIZE, which uses a percentage of the parent’s width (or height).
• The correct way to handle exceptions is to throw it until it can no longer be thrown, so that’s why we handle it in onEvent and not on doInsert.
• The user interface is initialized i n initUI and the events are handled in onEvent.


Now we will run the sample as a Java application.

• on Main tab:
   • Click menu Run / Run configurations
   • Right click Java Application / New
   • Name: HelloTC on Android
   • Project: HelloTC
   • Main class: totalcross.Launcher

• on Arguments tab:
• Program arguments: /scr android /r {put your key here} tc.sample.HelloTC
Note: you must pass the key you received by email when you subscribed or you will get an error message.
• 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:


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.

• Run / Run configurations
• Right click “HelloTC on Android” and select Duplicate
• Name: HelloTC on iPhone
• on Arguments tab:
• Program arguments: /scr 1920x1080x24 /fontsize 40 /scale 0.25 /r {put your key here} tc.sample.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.

• Click Run / Run Configurations
• Right-click Java Application, New
• Name: HelloTC deploy
• Main tab:
• Main class: tc.Deploy

• Arguments tab:
• Program arguments: tc/sample/HelloTC.class /r –all
• Working directory: Other
• Click Workspace, select HelloTC / classes (or bin) folder

• 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 “TotalCross3/docs /TotalCross Companion.pdf” to see the other deployment options.

You can download the whole project from HERE.

There’s a pre-compiled sample at TotalCross3/dist/samples/TotalCrossAPI that shows all user interface, io, net and util samples. It is also available in the Android Play store.