Penlets.com provides resources for users and developers of the Pulse smart pen from LiveScribe.
Subscribe: RSS Feed - Developers Group
Tutorial
Using a Shared Library
Tutorial by Robert HansonThe more you code, the more you find that you are able to reuse some of what you have already written. In this tutorial I want to show you the absolute easiest way to accomplish this, and point you to the Penlets.com Tools Library.
The General How-To
The current iteration of the PDK will compile your source code, create a jar from the compiled classes, and upload the finished jar to the pen. In my experimentation the easiest way to introduce an external source of classes is to tweak the source path in the build.xml of your project.
Below is the build.xml from the U.S. Capitals Trivia game.
<project name="US Capital Trivia" basedir="." default="dist">
<property name="PENLETSDK_HOME"
location="C:\Prerelease_Livescribe_Penlet_SDK\0.6\penletsdk"/>
<property name="common.builddir" value="/build" />
<property name="java.src.dir" value="src/java"/>
<import file="/build-common.xml" optional="false" />
</project>
With the exception of the project name and path to the PDK, it should look exactly like the one you use on every penlet project. Now the question is, what is the absolute easiest way to introduce an addition aource path?
Simply add one or more additional source paths to the
java.src.dir
property, separated by semi-colons.
<property name="java.src.dir"
value="src/java;../penlets-tools-lib/src/java"/>
You can use relative or absolute paths. In this case I used a relative path that points up one directory to my Penlets.com Tools Library.
Setting up your IDE
Begin by creating a new project in your IDE, just like any other penlet project. If you are unsure how to do this, take a look at our tutorial on Developing Penlets in Eclipse or read the developer documentation that ships with the PDK.
Once you have your shared project you need to add a reference to it from the penlet project that will use the shared library.
In Eclipse you right-click on your penlet project, select Build Path, then Configure Build Path. Then on the Projects tab you add your shared library project.
In NetBeans you can add the shared source by right-clicking your project, select Properties, and add the source folder to the Java Sources Classpath property page.
Comments (View) blog comments powered by DisqusProject Information
Tested for use with: PDK 0.6
Download the source code for this tutorial.
Download Source Code (zip)
New Tutorials
Using a Shared Library
Learn how to create a library of utils that you can
share between projects.
Capturing Drawn Shapes
Learn how to capture shapes drawn by the pen and determine relationships.
Penlets 101
Never written a penlet before? Then start here with Penlets 101!
Creating a Custom Vocabulary
Learn how to create a custom vocabulary for your ICR applications.
Using Properties Files
J2ME lacks a Properties class. In this tutorial we roll our own,
along with split and chomp functions.