This document explains how to convert a standalone app into a sandboxed app.
- Use the wizard to create a new sandboxed app
- File → New → MicroEJ Sandboxed Application Project
- Open the
module.ivy
file from the standalone project - Copy all the dependencies located in
<dependencies></dependencies>
- Open the
module.ivy
file from the sandboxed project - Paste the copied dependencies into
<dependencies></dependencies>
- Add the following dependency :
<dependency org="ej.library.wadapps" name="framework" rev="1.11.0" />
- From the standalone project, copy the content of
src/main/java
- Paste it into
src/main/java
in the sandboxed project. - From the standalone project copy the content of
src/main/resources
- Paste it into
src/main/resources
in the sandboxed project.
A sandboxed app needs a specific entry point which is not the main of the standalone app.
- If you have a GUI (i.e. using a GUI library such as MicroUI):
- Create a new class implementing
ej.wadapps.app.Activity
. - On the onStart(), call your project’s main.
- Create a new class implementing
- If you do not have any GUI:
- Create a new class implementing
ej.wadapps.app.BackgroundService
. - On the onStart(), call your project’s main.
- Create a new class implementing
- Move the system.properties except the services declarations to
the application.properties file
- In your code, replace the calls to
System.getProperty()
by calls toServiceLoaderFactory.getServiceLoader().getService(ApplicationsManager.class).getCurrentApplication().getProperty()
- In your code, replace the calls to
- For each local service declared
- create a file with the fully qualified name of the service in the folder services
- write one line containing the fully qualified name of the implementation class into this file
- Update the
MANIFEST.MF
:- Set the Application-Activities to the created activities (if you have a GU).
- Set the Application-BackgroundServices to the created background services (if you do not have a GUI).
- Right Click on the project
- Select Run as -> MicroEJ Application
- Select BackgroundServicesStandalone or ActivitiesStandalone
- Select your virtual device
- Press Ok
- Right Click on /src/.generated~/.java/YourProject/generated/YourProjectEntryPoint.java
- Select Run as -> Run Configurations…
- Select MicroEJ Application configuration kind
- Click on New launch configuration icon
- In Execution tab
- In Target frame, in Platform field, select a relevant virtual device
- In Execution frame
- Select Execute on Device
- In Settings field, select Build & Deploy
- In Configuration tab
- In Board frame
- Set Host field to your board IP address
- In Board frame
- Press Apply
- Press Run