Sun Microsystems V2.0 Welding System User Manual


 
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-app
and
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.