Sun Microsystems V2.0 manual Manifest and resources, Excluding files from the compilation

Page 13

Excluding files from the compilation

To exclude files or folders matching a specific pattern from the java compilation, set the ant property spot.javac.exclude.src, either on the command line with –D or in the build.properties file of the project. The value of the property should be specified using standard ant wildcarding.

For example, to exclude all source files in all “unittests” folders, use:

spot.javac.exclude.src=**/unittests/*

Manifest and resources

The file MANIFEST.MF in the resources/META-INFdirectory contains information used by the Squawk VM1 to run the application. In particular it contains the name of the initial class. It can also contain user-defined properties that are available to the application at run time.

A typical manifest might contain:

MIDlet-Name: Air Text demo

MIDlet-Version: 1.0.0

MIDlet-Vendor: Sun Microsystems Inc

MIDlet-1: AirText, , org.sunspotworld.demo.AirTextDemo

MicroEdition-Profile: IMP-1.0

MicroEdition-Configuration: CLDC-1.1

SomeProperty: some value

The syntax of each line is:

<property-name>:<space><property-value>

The most important line here is the one with the property name MIDlet-1”. This line has as its value a string containing three comma-separated arguments. The first argument is a string that provides a name for the application and the third defines the name of the application's main class. This class must be a subclass of javax.microedition.midlet.MIDlet. The second argument defines an icon to be associated with the MIDlet, which is currently not used.

The application can access properties using:

myMidlet.getAppProperty("SomeProperty");

All files within the resources directory are available to the application at runtime. To access a resource file:

InputStream is = getClass().getResourceAsStream("/res1.txt");

This accesses the file named “res1.txt” that resides at the top level with the resources directory.

Other user properties

For properties that are not specific to the application you should instead use either

persistent System properties (see section Persistent properties) for device-specific properties

properties in the library manifest (see section Library manifest properties

Each library extension must contain a file named

1The Squawk VM is the Java virtual machine that runs on the Sun SPOT. For more details, go to http://research.sun.com/projects/squawk/.

13

Image 13
Contents Page Page Contents Http protocol support Introduction Deploying and running a sample application Building and deploying Sun Spot applicationsBuild Successful Total time 3 seconds \MyApplication Ant -Dport=COM2 info Total time 4 seconds \MyApplication Total time 0 seconds \MyApplication Incorporating utility classes into your application Deploying a pre-existing jarExcluding files from the compilation Manifest and resourcesOther user properties Built-in properties Using the BasestationOverview Set up Remote operation Base Station configurationIntroduction Connect a Sun Spot base station Managing keys and sharing Sun SPOTs Using short names for SPOTsTake suitable actions during over-the-air downloads BackgroundSharing Sun SPOTs Changing the owner of a Sun SpotDeploying and running a host application What is protected?Generating a new key-pair LimitationsYour own host application Configuring network featuresIncorporating pre-existing jars into your host application Mesh routingTrace route Hardware configurations and USB powerLogging Page Threads Overview of an applicationThread priorities Sun Spot device library Sun Spot device librariesDevice Interface Persistent properties Overriding the Ieee address Accessing flash memoryUsart Radio communication library Program Radiogram protocol Server end Client endYou can open server radiogram connections in a similar way Broadcasting Radio properties Turning the receiver off and on Monitoring radio activity Conserving power using deep sleep modeShallow Sleep Deep Sleep Activating deep sleep modePreconditions for deep sleeping USB inhibits deep sleepDeep sleep behaviour of the standard drivers Device Condition to permit deep sleepWriting a device driver Http protocol support Configuring the http protocolSocket Proxy GUI mode Configuring projects in an IDEJavadoc/source configuration Classpath configurationDebugging Ant selectapplication Configuring Eclipse as a debug client Configuring NetBeans as a debug clientAdvanced topics Using library suitesWith adderlib as your current directory, execute the command Use the command Using the spot client SpotSerialPortException other exception in serial port comms Persistent system properties ReferenceProperty name Meaning Contents of the lib directory Contents of the arm directoryMemory usage Start address Space UseContents of the bin directory preverify.exe Contents of the tests directory Contents of the upgrade directory