Sun Microsystems V2.0 manual Building and deploying Sun Spot applications

Page 6

Building and deploying Sun SPOT applications

Deploying and running a sample application

The normal process for creating and running an application (assuming you are working from the command line rather than an IDE) is:

Create a directory to hold your application.

Write your Java code.

Use the supplied ant script to compile the Java and bind the resulting class files into a deployable unit.

Use the ant script to deploy and run your application.

In this section we will describe how to build and run a very simple application supplied with the SDK. Each step is described in detail below.

1.The directory Demos/CodeSamples/SunSpotApplicationTemplate contains a very simple Sun

SPOT application that can be used as a template to write your own.

The complete contents of the template directory should be copied to the directory in which you wish to do your work, which we call the root directory of the application. You can use any directory as the root of an application. In the examples below we have used the directory

C:\MyApplication.

All application root directories have the same layout. The root directory contains two files - build.xml and build.properties – that control the ant script used to build and run applications. The root directory also contains three sub-directories. The first, named src, is the root of the source code tree for this application. The second, named nbproject, contains project files used if your IDE is Netbeans. The third, named resources, contains the manifest file that defines the application plus any other resource files that the application needs at run time. Other directories will appear during the build process.

2.Compile the template example and create a jar that contains it by using the “ant jar-app command. The created jar is called imlet.jar and is created in the suite folder.

C:\MyApplication>ant jar-app

Buildfile: build.xml

-pre-init:

-init-user:

-init-system:

-do-init:

-post-init:

init:

-set-jar-name:

-pre-clean:

-do-clean:

6

Image 6
Contents Page Page Contents Http protocol support Introduction Building and deploying Sun Spot applications Deploying and running a sample applicationBuild Successful Total time 3 seconds \MyApplication Ant -Dport=COM2 info Total time 4 seconds \MyApplication Total time 0 seconds \MyApplication Deploying a pre-existing jar Incorporating utility classes into your applicationManifest and resources Excluding files from the compilationOther user properties Using the Basestation Built-in propertiesOverview Set up Base Station configuration Remote operationIntroduction Connect a Sun Spot base station Take suitable actions during over-the-air downloads Using short names for SPOTsManaging keys and sharing Sun SPOTs BackgroundChanging the owner of a Sun Spot Sharing Sun SPOTsGenerating a new key-pair What is protected?Deploying and running a host application LimitationsIncorporating pre-existing jars into your host application Configuring network featuresYour own host application Mesh routingHardware configurations and USB power Trace routeLogging Page Overview of an application ThreadsThread priorities Sun Spot device libraries Sun Spot device libraryDevice Interface Persistent properties Accessing flash memory Overriding the Ieee addressUsart Radio communication library Program Radiogram protocol Client end Server endYou can open server radiogram connections in a similar way Broadcasting Radio properties Turning the receiver off and on Conserving power using deep sleep mode Monitoring radio activityShallow Sleep Activating deep sleep mode Deep SleepDeep sleep behaviour of the standard drivers USB inhibits deep sleepPreconditions for deep sleeping Device Condition to permit deep sleepWriting a device driver Configuring the http protocol Http protocol supportConfiguring projects in an IDE Socket Proxy GUI modeClasspath configuration Javadoc/source configurationDebugging Ant selectapplication Configuring NetBeans as a debug client Configuring Eclipse as a debug clientUsing library suites Advanced topicsWith adderlib as your current directory, execute the command Use the command Using the spot client SpotSerialPortException other exception in serial port comms Reference Persistent system propertiesProperty name Meaning Memory usage Contents of the arm directoryContents of the lib directory Start address Space UseContents of the bin directory preverify.exe Contents of the upgrade directory Contents of the tests directory