Launch a sample

You can test the compiled examples. The classpath must include all the libraries needed by any of the samples, that are all located in your local Maven repository:

#> java -Djava.library.path=target\rxtx-native-libs -cp target\examples\communication\
SendBroadcastDataSample\send-broadcast-data-sample-0.1-SNAPSHOT.jar;target\
library\xbeejapi-0.1-SNAPSHOT.jar;<local_maven_repo_path>\org\rxtx\rxtx\2.2\
rxtx-2.2.jar;<local_maven_repo_path>\org\slf4j\slf4j-api\1.7.7\slf4j-api-1.7.7.jar;
<local_maven_repo_path>\org\slf4j\slf4j-jdk14\1.7.7\
slf4j-jdk14-1.7.7.jar com.digi.xbee.api.sendbroadcastdata.MainApp

Where <local_maven_repo_path> is the path to your local repository, by default ~/.m2/repository.

Or use Maven to test the compiled examples:

  1. In a console session and in the XBee Java Library directory, execute the following command to install the artifact you've generated (the JAR file) in your local repository:
#> mvn install

Maven compiles all the sources, executes the unit tests, and creates a JAR file for the library and every sample inside the target directory in the root of the the XBee Java Library folder.

  1. Go to the desired example directory, where the pom.xml of the sample is located, and locate the Send Broadcast Data sample.
#> cd examples/communication/SendBroadcastDataSample
  1. Execute the following command to execute the application.
#> mvn exec:exec
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread
count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Send Broadcast Data Sample 1.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.3.2:exec (default-cli) @ receive-broadcast-data-sample ---
  +------------------------------------------------+
  |  XBee Java Library Send Broadcast Data Sample  |
  +------------------------------------------------+

nov 03, 2014 11:34:46 AM com.digi.xbee.api.XBeeDevice open
INFO: [COM1 - 9600/8/N/1/N] Opening the connection interface...
WARNING:  RXTX Version mismatch
	 Jar version = RXTX-2.2pre1
	 native lib Version = RXTX-2.2pre2
nov 03, 2014 7:34:47 AM com.digi.xbee.api.XBeeDevice open
INFO: [COM1 - 9600/8/N/1/N] Connection interface open.
Sending broadcast data: 'Hello XBee World!'...
Success
nov 03, 2014 11:34:47 AM com.digi.xbee.api.XBeeDevice close
INFO: [COM1 - 9600/8/N/1/N] 0013A2004055BB5E (XBPRO900 232 Adapter) - Connection interface closed.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.857 s
[INFO] Finished at: 2014-11-03T11:34:47+01:00
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------