Sun Microsystems V2.0 manual Deploying a pre-existing jar

Page 12

[java] --------------------------------------------------------------------

[java] Hits - Class:95.74% Monitor:92.38% Exit:100.00% New:98.43%

[java] GCs: 2 full, 0 partial

[java] ** VM stopped: exit code = 0 **

[java] Exiting

[delete] Deleting: C:\SunSPOT\dev\temp\spot-temp-674916937

-post-run:

run:

BUILD SUCCESSFUL

Total time: 10 seconds

C:\MyApplication>

As you can see, this application just prints “Hello world!” However, it gives you a framework to use for your applications.

N.B. After your Sun SPOT has printed “Hello world!” it probably will not exit immediately. Instead, you will have to push the control button to force it to exit. This is because by default, Sun SPOTs run a background thread which listens for over-the-air commands. You can disable this behaviour if you wish. For more details, see the section Ensure that the remote Sun SPOT is executing the OTA Command Server.

As a shortcut, the ant command “deploy” combines jar-appand jar-deploy. Thus we could build, deploy and run the application with the single command line:

ant deploy run

Deploying a pre-existing jar

To deploy an application that has already been built into a suitable jar (by using the “ant jar-app command described earlier), use the “ant jar-deploy command with a command line option to specify the path to the jar:

ant jar-deploy -Djar.file=myapp.jar

Incorporating utility classes into your application

You can include code from pre-existing jar files as part of your application. We refer to jars used in this way as utility jars. A utility jar is built in the normal way using “ant jar-app”. To include a utility jar as part of your application specify it using -Dutility.jars=<filename>”, e.g.

ant deploy –Dutility.jars=util.jar

You can specifiy multiple utility jars as a list separated by a classpath delimiter (“;” or “:”). Note that you may need to enclose the list in quotes. Also, the classes in the utility jars must all be preverified. One way to ensure this is to create the jar using

ant jar-app

Resource files in utility jars will be included in the generated jar, but its manifest is ignored.

If you have code that you want to include as part of all your applications you might consider building it into the system library – see the section Advanced topics in this document.

12

Image 12
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 Using short names for SPOTs Managing keys and sharing Sun SPOTsTake suitable actions during over-the-air downloads BackgroundChanging the owner of a Sun Spot Sharing Sun SPOTsWhat is protected? Deploying and running a host applicationGenerating a new key-pair LimitationsConfiguring network features Your own host applicationIncorporating pre-existing jars into your 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 SleepUSB inhibits deep sleep Preconditions for deep sleepingDeep sleep behaviour of the standard drivers 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 Contents of the arm directory Contents of the lib directoryMemory usage Start address Space UseContents of the bin directory preverify.exe Contents of the upgrade directory Contents of the tests directory