Project Sun SPOT > >     Getting Started with Sun SPOTs

Getting Started with Sun SPOTs

More Information
» Video presentation on Sun SPOTs

» ZDNet video introducing Sun SPOTs

» Sun SPOTs at Java.net

» Sun SPOT Community Forums

Sun SPOTs (Sun Small Programmable Object Technology) are small, wireless, battery-powered devices developed at Sun Labs to explore the next frontier of network computing. These devices can be used in a wide range of applications including robotics, environmental monitoring, asset tracking, proactive health care and many others. Sun SPOTs are powered by a specially designed small-footprint Java virtual machine, called Squawk, that can host multiple applications concurrently, and requires no underlying operating system. Stackable boards include application-specific sensors and actuators such as accelerometers, light detectors, temperature sensors, LEDs, push buttons and general I/O pins. The devices can be duty cycled to run for months on a single charge of their rechargeable battery.

With current state-of-the-art, developing applications for most other embedded devices is a tedious chore -- often involving learning unfamiliar languages/tools with little or no debugging support. By supporting application development and debugging via standard IDEs such as NetBeans, our platform opens up the exciting world of embedded programming to a much broader class of developers. Sun SPOTs have been commercially available at sunspotworld.com since March 2007 and have been used in several high profile technology demonstrations with Sun customers and partners, at university courses and even art installations. They are also proving to be a popular platform for hobbyists and researchers. Sun SPOTs have been featured on Infoworld's list of Must-have gadgets and Javalobby's list of Amazing Java Applications. Click on the video presentation link in the right column to learn more about Sun SPOTs.

The Sun SPOT Software Development Kit (SDK) includes the necessary documentation, code samples and software to help you develop applications for SPOTs. The SDK also includes an emulator so users that do not have any Sun SPOT devices can still develop and run applications on virtual SPOTs. All of the Sun SPOT SDK (and even the hardware) is available as open source from Java.net.

The rest of this document describes how to download and install the software necessary to program Sun SPOTs


Table of Contents

  1. Prerequisites
  2. Installing and Configuring Prerequisite Software on
  3. Installing Sun SPOT SDK with SPOT Manager
  4. Next Steps

1. Prerequisites

Before you can develop applications using the Sun SPOT SDK, you'll need to make sure that your system has some additional software. In particular, you'll need:

  1. Java Development Kit (JDK) from Sun Microsystems, version 5 (aka JDK 1.5) or later
  2. Apache Ant, version 1.6.5 or later
  3. NetBeans Integrated Development Environment (IDE), version 5.5 or later

Of these, the first two are essential. NetBeans (or another IDE) is optional but highly recommended, especially for users new to Java programming. Many of the readme files for the packaged demos assume that the user is developing with NetBeans.

The SPOT SDK is installed via an application called SPOT Manager. which can also check for the prerequisite software. Since SPOT Manager is itself written in the Java programming language, it needs at least a working Java Runtime Environment (JRE), if not a full Java Development Kit (JDK), to run. Note that the JDK includes everything in the JRE plus additional software, such as the Java language compiler (javac) needed to develop Sun SPOT applications.

Click here to test your system for a functioning JRE. If you see a dancing Duke logo, a JRE is already installed and you can skip to Installing Sun SPOT SDK with SPOT Manager. Otherwise, follow the instructions for Installing and Configuring Prerequisite Software.


2. Installing and Configuring Prerequisite Software

Experienced Java users may already have some of the prerequisite software installed, and any missing components can be obtained from their project specific websites:

  1. http://java.sun.com/javase/downloads/index.jsp (for JDK aka Java SE)
  2. http://ant.apache.org/bindownload.cgi (for Apache Ant)
  3. http://www.netbeans.org (for NetBeans)

New users can simplify this process by downloading and installing the combination of NetBeans (which includes Ant) and the JDK. Irrespective of how you install the pre-requisite software, you'll also need to configure some system settings so SPOT Manager can find it. Specific instructions for Windows Vista, Windows XP, Linux, Solaris and Mac OS X platforms are included below. After following these instructions, proceed to Installing Sun SPOT SDK with SPOT Manager.

Windows Vista

Log in as administrator, point your browser at http://java.sun.com/javase/downloads/netbeans.html and click on the Download button. This will bring up a new web page where you should specify Windows as your platform, check the box to accept software terms and conditions, and click Continue. The next web page will have the name of an executable file, e.g. jdk-6u6-nb-6_1-windows.exe The actual name might change slightly as new updates to NetBeans or the JDK become available. Launch this executable by clicking on it and choosing Run when asked Do you want to run or save this file?. This will start the NetBeans/JDK combo installer. Click through the various pop ups (accepting the default choices) to finish installing NetBeans and the JDK.

Next, we need to set the JAVA_HOME and ANT_HOME environment variables to point to the folders where the JDK and Ant are installed. We also need to modify the PATH variable to include the full path to the JDK and Ant binaries (e.g. javac).

If you followed the instructions above, the JDK should reside in C:\Program Files\Java\jdk1.6.0_06, Ant in C:\Program Files\NetBeans 6.1\java2\ant, the JDK binaries in C:\Program Files\Java\jdk1.6.0_06\bin and the Ant binaries in C:\Program Files\NetBeans 6.1\java2\ant\bin. If you downloaded a different update of the JDK or NetBeans or installed them in a location other than the default, you'll need to adjust these appropriately.

  1. Click Start and select Control Panel. Enter env into the search box and when search results show up, click Edit the system environment variables > Continue > Environment Variables


  2. Check the System Variables section to see if JAVA_HOME is already set. If it isn't, select New and enter JAVA_HOME for Variable Name and C:\Program Files\Java\jdk1.6.0_06 for Variable Value. Otherwise, click Edit and modify the text box labelled Variable Value to C:\Program Files\Java\jdk1.6.0_06. Press OK.


  3. Next, check if ANT_HOME is already set. If it is, click Edit and modify the text box labelled Variable Value to C:\Program Files\NetBeans 6.1\java2\ant. Otherwise, select New and enter ANT_HOME for Variable Name and C:\Program Files\NetBeans 6.1\java2\ant for Variable Value. Press OK.

  4. Back in the System Variables section of the Environment Variables pop up, select Path and click Edit. Insert %JAVA_HOME%\bin;%ANT_HOME%\bin; at the beginning of the text box labelled Variable Value. Press OK.


  5. You'll also need to turn off User Account Control for the SPOT SDK installation to succeed. You can turn it back on, if required, after the SDK is installed.
    Click Start > Control Panel > User Accounts > User Accounts > Turn User Account Control on or off. Uncheck the box labelled "Use User Account Control (UAC) to help protect your computer" and press OK. Reboot for the settings to take effect.




Windows XP

Point your browser at http://java.sun.com/javase/downloads/netbeans.html and click on the Download button. This will bring up a new web page where you should specify Windows as your platform, check the box to accept software terms and conditions, and click Continue. The next web page will have the name of an executable file, e.g. jdk-6u6-nb-6_1-windows.exe The actual name might change slightly as new updates to NetBeans or the JDK become available. Launch this executable by clicking on it and choosing Run when asked Do you want to run or save this file?. This will start the NetBeans/JDK combo installer. Click through the various pop ups (accepting the default choices) to finish installing NetBeans and the JDK.

Next, we need to set the JAVA_HOME and ANT_HOME environment variables to point to the folders where the JDK and Ant are installed. We also need to modify the PATH variable to include the full path to the JDK and Ant binaries (e.g. javac).

If you followed the instructions above, the JDK should reside in C:\Program Files\Java\jdk1.6.0_06, Ant in C:\Program Files\NetBeans 6.1\java2\ant, the JDK binaries in C:\Program Files\Java\jdk1.6.0_06\bin and the Ant binaries in C:\Program Files\NetBeans 6.1\java2\ant\bin. If you downloaded a different update of the JDK or NetBeans or installed them in a location other than the default, you'll need to adjust these appropriately.

  1. Click Start and select My Computer > Properties > Advanced > Environment Variables.
  2. Check the System Variables section to see if JAVA_HOME is already set. If it isn't, select New and enter JAVA_HOME for Variable Name and C:\Program Files\Java\jdk1.6.0_06 for Variable Value. Otherwise, click Edit and modify the text box labelled Variable Value to C:\Program Files\Java\jdk1.6.0_06. Press OK.
  3. Next, check if ANT_HOME is already set. If it is, click Edit and modify the text box labelled Variable Value to C:\Program Files\NetBeans 6.1\java2\ant. Otherwise, select New and enter ANT_HOME for Variable Name and C:\Program Files\NetBeans 6.1\java2\ant for Variable Value. Press OK.
  4. Back in the System Variables section of the Environment Variables pop up, select Path and click Edit. Insert %JAVA_HOME%\bin;%ANT_HOME%\bin; at the beginning of the text box labelled Variable Value. Press OK.

Linux

Point your browser at http://java.sun.com/javase/downloads/netbeans.html and click on the Download button. This will bring up a new page where you should specify Linux as your platform, click on the checkbox (to accept software terms and conditions) and hit the Continue button. This will bring up a page with the name of an executable file, e.g. jdk-6u6-nb-6_1-linux.sh The actual name might change slightly as new updates to NetBeans or the JDK become available. Click on the file name to download it. Make that file executable and launch it:

	% chmod ugo+x jdk-6u6-nb-6_1-linux.sh
	% ./jdk-6u6-nb-6_1-linux.sh          
   
This will start the NetBeans/JDK combo installer. Click through the various pop ups (accepting the default choices) to finish installing NetBeans and the JDK in your home directory.

If you followed the instructions above, the JDK should reside in /home/<user_name>/jdk1.6.0_06, Ant in /home/<user_name>/netbeans-6.1/java2/ant, the JDK binaries in /home/<user_name>/jdk1.6.0_06/bin and the Ant binaries in /home/<user_name>/netbeans-6.1/java2/ant/bin. If you downloaded a different update of the JDK or NetBeans or installed them in a location other than the default, you'll need to adjust these appropriately.

Next, we need to set the JAVA_HOME and ANT_HOME environment variables to point to the folders where the JDK and Ant are installed. We also need to modify the PATH variable to include the full path to the JDK and Ant binaries (e.g. javac).

On an Ubuntu or similar system, append the following lines at the end of your .bashrc file. Logout and log back in for these system settings to take effect.

	export JAVA_HOME=/home/<user_name>/jdk1.6.0_06
	export ANT_HOME=/home/<user_name>/netbeans-6.1/java2/ant
	export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
    

Solaris x86

The Sun SPOT SDK requires Solaris 11 (look for "5.11" in the output of the "uname -r" command) and JDK 1.5. There are known issues with using JDK 1.6 on Solaris for Sun SPOT development. Even though JDK 1.6 is the default on Solaris 11, a version of JDK 1.5 is also pre-installed. The latter can be activated by changing the symlink /usr/java as follows:

       # cd /usr
       # rm java
       # ln -s jdk/jdk1.5.0_13 java
    
The actual name might be slightly different depending on the specific JDK 1.5 update available on your system. NetBeans (which includes Ant) is also pre-installed in the /opt directory. We just need to set the JAVA_HOME, ANT_HOME and PATH variables correctly.

Append the following lines at the end of your .bashrc file. Logout and log back in for these system settings to take effect.

	export JAVA_HOME=/usr/java
	export ANT_HOME=/opt/netbeans-6.0/java1/ant
	export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
    
Again, the actual path names may differ slightly depending on what version of JDK/NetBeans is installed on your system so be sure to make appropriate adjustments.

Mac OS X

Mac OS X users should install the Apple Developer Tools. This will ensure that both a JDK and Ant are installed. NetBeans can be downloaded separately from the main project web site.

  1. Point your browser at http://developer.apple.com/tools/download/ and download Xcode 3.0 (requires a free signup with Apple Developer Community).
  2. Double-click on XcodeTools.mpkg. Click through the various pop ups and proceed with default options for installing Xcode Tools.
  3. Point your browser at http://download.netbeans.org/netbeans/6.1/final/ and in the upper right hand corner, select the Language of your choice and the Platform as Mac OS X. Click on the Download button in the third column (labelled Java SE). Double click on the NetBeans IDE 6.1.mpkg icon you'll see when you open the downloaded disk image.
  4. This will launch the NetBeans installer. Click Continue on the Install NetBeans IDE 6.1 window:
  5. Click Continue on the Software License Agreement and Agree to the terms of the agreement. Click through the various pop ups and proceed with default options for installing NetBeans IDE 6.1.
  6. Finally, click on Close.
  7. You can make sure that the JDK and Ant software is installed properly by invoking the java and ant commands with the -version argument. The actual output you see might be slightly different depending on the version installed.
    	  % java -version
              java version "1.5.0_13"
              Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-237)
              Java HotSpot(TM) Client VM (build 1.5.0_13-119, mixed mode, sharing)
    
              % ant -version
              Apache Ant version 1.6.5 compiled on September 12 2006
    	


3. Installing Sun SPOT SDK with SPOT Manager

You install the Sun SPOT SDK and demos using Sun SPOT Manager, a Java application available over the web. Follow these steps:

  1. Navigate to the SPOT Manager web page and click on the image of the Sun SPOT to launch the Sun SPOT Manager application. On some platforms, your browser may not know how to deal with .jnlp files. If this happens, configure it to open such files with the javaws application stored inside the folder containing the JDK binaries.
  2. A splash screen with an image of a Sun SPOT will appear followed by the Sun SPOT Configuration Validator screen. Click the Start button. This checks to make sure that the JDK, Ant, and NetBeans are installed and configured correctly.
  3. If the steps outlined in Installing and Configuring Prerequisite Software were completed successfully, you should see the Configuration Validator display "Congratulations! Your configuration is sufficient to run the Sun SPOTs SDK"
    If your configuration is incorrect, click Show Log and attempt to diagnose. Revisit the section Installing and Configuring Prerequisite Software and make sure that you've not only installed the prerequisite software but also configured the appropriate system settings for your platform, e.g. JAVA_HOME, ANT_HOME.
    On some Linux platforms, you might see SPOT Manager complain about missing software even after you've installed and configured the JDK/NetBeans combo. If that happens, quit SPOT Manager and relaunch it from the command line as:
               % javaws http://www.sunspotworld.com/SPOTManager/SPOTManager.jnlp
            
  4. Once the validation checks pass, press OK to bring up the "Sun SPOT Manager Tool" window which lets you choose the version of the SPOT SDK to install. Click the SDKs tab. If you don't see any blue (aka version 4.0) release of the SDK in the right side scroll list, click on the Preferences tab, choose Dev Preview and return to the SDKs tab. Select the latest blue SDK and click Install.
  5. The Sun SPOT SDK License Agreement appears. You must scroll to the bottom before the Accept button activates. Read the agreement and click Accept.
  6. The Sun SPOTs SDK Installer Tool appears. Click the Install button.
    Windows users might see a popup warning them of potential problems with the Sun SPOT Emulator if they install the SDK in the default folder whose full path has spaces. This warning can be ignored for the latest blue SDK.
  7. SPOT Manager starts downloading the Sun SPOT SDK. This could take a while depending on the speed of your network connection.

  8. On Mac OS X, SPOT Manager additionally sets up the /var/lock directory which is used by the USB communication software (RXTX). In particular, it creates this directory, changes its group to uucp, makes the directory readable/writable/executable by uucp and adds the user to the uucp group. This is the equivalent of typing the following commands in a terminal window:
    	% sudo mkdir /var/lock
    	Password:
    	% sudo chgrp uucp /var/lock 
    	% sudo chmod 775 /var/lock 
    	% sudo dscl 	 
    	Entering interactive mode... (type "help" for commands) 
    	> append /Local/Default/Groups/_uucp users your_user_name 
    	> ^DGoodbye 
    	
    The following screen shots show a terminal window that's opened by SPOT Manager to execute the commands listed above.


4. Next Steps

The SPOT SDK is normally installed in C:\Program Files\Sun\SunSPOT\sdk on Windows and under SunSPOT/sdk in the user's home directory on Linux, Solaris and Mac OS X. After a successful SDK installation, we recommend that you explore the Sun SPOT Tutorial to learn about writing, deploying and running SPOT applications. You can either do this with virtual (aka emulated) SPOTs or with physical SPOT devices.

If you will be using physical devices, there are a couple of additional steps to follow.

  1. Windows: When you plug in a Sun SPOT to the USB port of your Windows (XP or Vista) host computer, you might see a message saying Windows has detected new hardware and needs to install the driver for it. If you point Windows to the directory in which the SDK is installed, it should be able to use the SunSPOT.inf file there to automatically install the driver. For example, when you see the "Welcome to the Found New Hardware Wizard" pop-up, chose Install from a list or specific location > Search for the best driver in these locations &, check the box Include this location in the search and add the path to the installed SDK (C:\Program Files\Sun\SunSPOT\sdk) and click Next.

    Linux: Linux users should make sure that support for USB devices is enabled in the kernel (enabled "CDC ACM support"). This is normally the case unless you are using a custom built kernel.

    Other: You should not have to do anything special on other (e.g. Mac OS X, Solaris x86) platforms for the Sun SPOT devices to be recognized.

  2. The version of the Sun SPOT SDK you installed based on the instructions above obsoletes the version installed on the Sun SPOT devices at the factory. So before following the tutorial, you should upgrade the software on your Sun SPOTs. To do this, connect your SPOT to the host computer via a USB cable, and from the SDK installation directory, execute the ant upgrade command (or ant upgrade startbasestation in the case of a basestation), e.g. On Windows, do
    	C:\Program Files\SunSPOT\sdk> ant upgrade
    	
    and on Solaris/MacOS/Linux, do
    	% cd
    	% cd SunSPOT/sdk
    	% ant upgrade
    	
    You can accomplish the same result with SPOT Manager by selecting the Sun SPOTs tab and clicking Refresh followed by Upgrade (in the case of a basestation, this should be followed by clicking BaseStation > Start Basestation).
    After the ant command finishes, disconnect the SPOT from the USB cable and press its reset button. Repeat the upgrade process for each one of your physical SPOTs.

You are now ready to explore the tutorial which can be accessed by opening the index.html document inside Docs\Tutorial subfolder of the SPOT SDK directory. Enjoy!