28
1070_0_Product_Manual - October 28, 2010 8:52 AM
Advanced User’s Guide
This section describes use of the PhidgetSBC outside of the web configuration, and basic opening of Phidgets over
the network. This includes custom applications, using the included gcc compiler, using SSH, customizing the system,
and building your own filesystem and/or kernel from sources. It is recommended that you have some experience
with Linux before trying some of these tasks.
Custom Applications
The PhidgetSBC supports custom user application written in either Java or C. Custom applications are set up and
managed using the configuration interface. Alternatively applications can also be created using the command line
tool ‘createapp’ - the tool will guide you through the set up process.
Custom applications are created under the /mnt/userspace/userapps/(application name) directory and contain all
application files. This must include at least the executable file.
Java applications must be compiled on a separate development machine, where they can also be tested before
deployment. When coding, make sure to include the correct version of phidget21.jar file as part of the environment.
You can use the link under Userspace: Applications page in the configuration interface to ensure that your Java
program is synchronized with the version of phidget21 on the PhidgetSBC. When using Java packages, make sure
to create the appropriate directory for them.
The PhidgetSBC also supports .jar files and you may find it easier to compile an upload a .jar instead of the all the
necessary .class files. When your project is completed we recommend to compile the project as a .jar. This reduces
the number of extra flies created into a single package that is easier to manage and can be executed from the
command line, or even by double clicking the file if you operating system environment is configured properly.
Under the command line, you can use the jar utility from the Java SDK to package the .class and .java files. The
process starts by going to the directory where your program is located and creating a manifest file. This manifest
file tells the java jar compiler the version of the program and the name of the Main-Class which acts as the entry
point for the application. The entry point is the class that contains the main method that is run when the program is
started. You also want to add a line to specify the class-path which will point to the phidget21.jar file that contains
the library for including into the jar.
Let’s assume we want to distribute our program MyProgram.java as an executable jar file. First, compile the
program to generate the .class files. Now, create the manifest file MyProgram.mf which contains the following lines:
Manifest-Version: 1.0
Class-Path: phidget21.jar
Main-Class: MyProgram
Save the file and close it. Create the jar by running the following command from the command line:
jar cmf MyProgram.mf MyProgram.jar MyProgram.class MyProgram.java SupportClass.class SupportClass.java
You should now have an executable jar file called MyProgram.jar that you can distribute easily as one package and
run from anywhere very easily. To run the executable jar file you can either type the following into the command
line:
java -jar MyProgram.jar
Or, you can double click the file in a visual operating system if your environment is configured properly.
Note:
Some IDEs, such as Eclipse and Netbeans, automatically create jar files when you build your project. Simply
look in your build output folders for your .jar file.
Java applications can also be directly executed through SSH using jamvm.
i.e.: jamvm –jar MyProgram.jar