The Basics: Tools
This document contains the following sections:
- Recommended Reading
- Overview
- Tools to Create and View webOS Applications
- Tools to Test and Debug webOS Applications
- Related Topics
Recommended Reading
We recommend that you read the following documents before going forward:
Overview
This document is geared toward the beginning HP webOS developer. Here we discuss the various application development tools—what they are and when to use them.
Note: Before running these commands, start the emulator (if applicable) and ensure that you are in your application's workspace directory.
Tools to Create and View webOS Applications
The following webOS command-line tools build, package, and install your application on the emulator:
- palm-generate
- palm-package
- palm-install
- palm-launch
The following sections provide an introduction to each of these tools. For details, see Command Line Tools.
palm-generate
When you are ready to start building your application, use palm-generate to create a functional application with a standard webOS application directory structure, which you can modify as your code grows. Take a look at the new directory to see everything you get from one simple, powerful tool.
The directory structure is built by using an application or scene name as arguments. Run this tool to create new applications or new scenes for an established application directory.
The following are examples of the palm-generate
command-line tool:
-
Create a new application in
~/projects/Ticker
and set the application title to "Stock Ticker":palm-generate -p "title=Stock Ticker" ~/projects/Ticker
-
Create a new application in
~/projects/Hello
and set the title, id, and version:palm-generate -p "{title:'Hello There', id:com.mystuff.hello, version:'2.1'}" ~/projects/Hello
-
Add a new scene named "First" to the application in
~/projects/Ticker
:palm-generate -t new_scene -p "name=First" ~/projects/Ticker
palm-package
When you are ready to view your application on a device or the emulator, use palm-package to create an installation package file (.ipkg ) containing all of the files in the application directory.
The following are examples of the palm-package
command-line tool:
-
Create a package for the application in
~/projects/Ticker
:palm-package ~/projects/Ticker
-
Create a package for the application in
~/projects/Ticker
and set the output directory to~/packages
:palm-package -o ~/packages ~/projects/Ticker
-
Create a package for the application in
~/projects/Ticker
, and exclude all text files and the tests directory:palm-package --exclude="*.txt" --exclude="tests" ~/projects/Ticker
palm-install
To install the application's installation package file on a device or in the emulator workspace, use palm-install
.
Note: If installing the application on a device, first enable Developer mode.
The following are examples of the palm-install
command-line tool:
-
Install the package (on the default device):
palm-install ~/projects/packages/com.example.app_1.0_all.ipk
-
Remove the application (from the default device):
palm-install -r com.example.app
-
List the applications (on the default device):
palm-install -l
-
List the applications on the usb-connected device:
palm-install -d usb -l
-
List the applications on the emulator:
palm-install -d tcp -l
palm-launch
To launch, list, or close applications on a device or the emulator, use palm-launch
.
The following are examples of the palm-launch
command-line tool:
-
Launch the application (on the default device):
palm-launch com.example.app
-
Launch the application with debugging options:
palm-launch -p "{mojoConfig: {debuggingEnabled:true}}" com.example.app
-
Close the application (on the default device):
palm-launch -c com.example.app
-
List the applications (on the default device):
palm-launch -l
-
List the applications on the usb-connected device:
palm-launch -d usb -l
-
List the applications on the emulator:
palm-launch -d tcp -l
Tools to Test and Debug webOS Applications
The following tools are for testing and debugging webOS applications:
- emulator
- inspector
- debugger
- webOS Resource Manager
- luna-send
Emulator
The emulator provides a virtual representation of a webOS device, allowing you to view and test your application. The emulator uses Oracle's® VirtualBox™. The following should get you started:
-
To start the emulator in Windows®, select
Start > All Programs > Palm > SDK > Palm Emulator
. -
For help with VirtualBox, start the emulator and select
Help > Contents
for the User Guide. If you are not familiar with the emulator, we suggest you read at least section 3.4, "Running a virtual machine," in Chapter 3, "Starting out with VirtualBox." -
To search for VirtualBox updates, start the emulator and select
Help > Check for Updates
. -
To uninstall the emulator, follow the instructions in Uninstalling the SDK.
Note: For more info, see Emulator, Emulator Screencasts, and Best Practices.
Inspector
The inspector lets you examine the document object model (DOM) of an application running on a device or the emulator; for more info, see Inspector. HP webOS supports the standard DOM Level 2 event model; for more info, see Wikipedia.
The following example enables the inspector:
palm-launch -i com.example.app
Debugger
The debugger tool allows you to use breakpoints, display variables, and trace the application stack. For more info, see Debugger.
webOS Resource Monitor
The webOS Resource Monitor evaluates an application's memory use, providing charts for your analysis. For more info, see webOS Resource Monitor.
luna-send
If your application uses the Location (GPS) Service or Phone API, you can test these features on the emulator by using the luna-send command. For more info, see [Radio Simulator] (/dev-guide/tools/luna-send.html).
The following are examples of the luna-send command-line tool:
-
Generate an incoming phone call:
luna-send -n 1 luna://com.palm.pmradiosimulator/set_incomingcall {\"number\":\"14086177431\"}
-
Generate an incoming SMS:
luna-send -n 1 luna://com.palm.pmradiosimulator/set_incomingsms {\"number\":\"4086177431\",\"message\":\"'Virtura Reality'\"}
-
Generate a GPS fix:
luna-send -n 1 luna://com.palm.pmradiosimulator/set_position {\"lat\":\"37.3\",\"long\":\"-122\"}
-
Change the operator name (on the next power cycle):
luna-send -n 1 luna://com.palm.pmradiosimulator/set_operator {\"operator\":\"Sprint\"}