Developing Java Applications: For Intermec Computers
Developing Java Applications: For Intermec Computers
Applications
for Intermec Computers
Intermec Technologies Corporation
Worldwide Headquarters
6001 36th Ave.W.
Everett, WA 98203
U.S.A.
www.intermec.com
The information contained herein is provided solely for the purpose of allowing customers to operate and service
Intermec-manufactured equipment and is not to be released, reproduced, or used for any other purpose without
written permission of Intermec Technologies Corporation.
Information and specifications contained in this document are subject to change without prior notice and do not
represent a commitment on the part of Intermec Technologies Corporation.
© 2010 by Intermec Technologies Corporation. All rights reserved.
The word Intermec, the Intermec logo, Norand, ArciTech, Beverage Routebook, CrossBar, dcBrowser, Duratherm,
EasyADC, EasyCoder, EasySet, Fingerprint, INCA (under license), i-gistics, Intellitag, Intellitag Gen2, JANUS,
LabelShop, MobileLAN, Picolink, Ready-to-Work, RoutePower, Sabre, ScanPlus, ShopScan, Smart Mobile
Computing, SmartSystems, TE 2000, Trakker Antares, and Vista Powered are either trademarks or registered
trademarks of Intermec Technologies Corporation.
There are U.S. and foreign patents as well as U.S. and foreign patents pending.
Microsoft, Windows, and the Windows logo are registered trademarks of Microsoft Corporation in the United
States and/or other countries.
Contents
Before You Begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
Global Services and Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
Warranty Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
Web Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
Telephone Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
Who Should Read This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vi
Related Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vi
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62
Web Support
Visit the Intermec web site at www.intermec.com to download our current manuals
(in PDF).
Visit the Intermec technical knowledge base (Knowledge Central) at
intermec.custhelp.com to review technical information or to request technical
support for your Intermec product.
Telephone Support
In the U.S.A. and Canada, call 1-800-755-5505.
Outside the U.S.A. and Canada, contact your local Intermec representative. To
search for your local representative, from the Intermec web site, click About Us >
Contact Us.
Related Documents
The Intermec web site at www.intermec.com contains our documents (as PDF files)
that you can download for free.
To download documents
1 Visit the Intermec web site at www.intermec.com.
2 Click the Products tab.
3 Using the Products menu, navigate to your product page. For example, to find
the CN3 computer product page, click Computers > Handheld Computers >
CN3.
4 Click the Manuals tab.
If your product does not have its own product page, click Support > Manuals. Use
the Product Category field, the Product Family field, and the Product field to
help you locate the documentation for your product.
Java ME Configurations
Java ME supports two configurations:
• Connected Limited Device Configuration (CLDC) is for resource-constrained
devices like mobile phones and entry-level personal digital assistants (PDAs). It
has a very limited set of APIs, and is designed to run on devices with limited
memory, processing power and graphics capabilities.
• Connected Device Configuration (CDC) is for network-connected devices that
have more memory and processing power, such as high-end PDAs.
Intermec Windows Mobile and CE-based computers are certainly in the high-end
PDAs category and meet the requirements of CDC; therefore, Intermec recommends
CDC for Intermec computers. The focus of this document is on the CDC.
CDC is a superset of CLDC; therefore, CLDC is upward compatible with CDC.
However, the CLDC Mobile Information Device Profile (MIDP) is not compatible
with CDC. If your existing application is based on MIDP and you do not wish to
revamp your application for CDC, you may install a JVM that supports MIDP such
as IBM WebSphere Everyplace Micro Environment with MIDP 2.0.
6 Click OK.
5 Click Finish.
import java.awt.*;
import java.awt.event.*;
m_ButtonClose.addActionListener(new ActionListener()
{
// Invoked when the Close button is clicked.
public void actionPerformed(ActionEvent e)
This simple application displays the “Hello World!” string in the north of the frame
and a Close button at the south of the frame. Click Close to exit the application.
Exporting to HelloWorld.jar
1 In the Package Explorer, right-click the src folder under HelloWorld and choose
Export from the popup menu.
2 In the Export dialog box, choose JAR file under the Java node and click Next.
3 In the JAR File Specification screen, click Browse. The Save As dialog box
appears.
In the JAR File Specification screen, the JAR file list now includes “HelloWorld/
HelloWorld.jar”. This specifies the output JAR file, HelloWorld.jar, will be
created in the HelloWorld project folder.
To create a runnable JAR, the JAR manifest needs to contain the Main-Class
attribute with the proper main class name. Continue with the next step to create
a runnable JAR, or continue with Step 8 to finish the export.
This compile warning appears because the HelloWorld Java class does not declare
the “static final long serialVersionUID” field. To avoid the compile warning, define
serialVersionUID properly using the UID obtained from the serialver utility
(included in JDK).
All screenshots in this section were captured using NetBeans 6.8 running on
Windows XP. You may download NetBeans from the NetBeans Download site.
There are different bundles of NetBeans you can choose to download. Intermec
recommends that you choose a bundle which includes Java ME.
6 In the Choose Platform Folder screen, browse to the installation folder of the
CrE-ME Developer Kit (default is “C:\Program Files\NSIcom\CrE-ME V4.12”)
and then click Next.
A new platform entry is added to the CDC node in the Java Platform Manager
dialog box.
import java.awt.*;
import java.awt.event.*;
m_ButtonClose.addActionListener(new ActionListener()
{
// Invoked when the Close button is clicked.
This simple application displays the “Hello World!” string in the north of the frame
and a Close button at the south of the frame. Click Close to exit the application.
6 Click OK.
7 In the Projects window, right-click the HelloWorld project and choose Run in
the popup menu. The IDE rebuilds the project and runs the HelloWorld
application in the CrEme emulator.
For more information regarding the specific VM options, refer to your JVM
documentation.
Remote Debugging
Remote debugging is possible if the JVM on the mobile computer and the IDE
support Java Platform Debugger Architecture (JPDA). Both the Eclipse and
NetBeans IDEs support remote debugging via JPDA. The IDE debugger can attach
to a remote Java application via JDPA transport.
Although WEME supports remote debugging, CrE-ME 4 does not. This section
walks you through the setup process to debug a Java application running in WEME
from either the Eclipse or NetBeans IDE. The common tasks involved in setting up
remote debugging are as follows:
1 Create an application shortcut that specifies debug options.
2 Deploy the application with the debug shortcut and start the debug session.
3 Set up the IDE JPDA transport to attach to the remote application.
The following sections provide more details for these tasks. Two separate tutorials
are provided for the Eclipse and NetBeans IDEs.
Setting Breakpoints
You can set breakpoints in the HelloWorld class before you launch the IDE
debugger. For example, you can set a breakpoint in the HelloWorld class at the
dispose() method in the actionPerformed method of the listener for the Close
button.
As soon as the debugger attaches to the remote VM, the application begins to
run. On the mobile computer, WEME (J9) launches the HelloWorld UI unless
there are breakpoints before the UI is displayed.
Setting Breakpoints
You may set some breakpoints in the HelloWorld class before you launch the IDE
debugger. For example, you may set a breakpoint in the HelloWorld class at the
dispose() method in the actionPerformed method of the listener for the Close
button.
As seen in the next screenshot, it sets a breakpoint at the dispose() method in the
actionPerformed method of the listener for the Close button. When the Close
button is clicked in the HelloWorld UI, the debugger breaks at the dispose() method.
try
{
// DB2eDataSource is in db2ejdbc.jar which is included in the
// DB2e installation CAB file.
com.ibm.db2e.jdbc.DB2eDataSource ds = new com.ibm.db2e.jdbc.DB2eDataSource();
ds.setUrl(url);
con = ds.getConnection();
st = con.createStatement();
try {
if (st!= null) st.close();
} catch (Exception e) {e.printStackTrace();}
try {
if (con != null) con.close();
} catch (Exception e) {e.printStackTrace();}
}
}
}
You can also run this sample in CrE-ME. The following is a shortcut for CrE-ME 4:
255#"\windows\CrEme\bin\CrEme.exe" -Of -classpath '\Program
Files\JDBCSample\JDBCSample.jar;\Windows\db2ejdbc.jar'
sample.JDBCSample
Note: The “-Of” option specifies the output will be redirected to jscpout.txt located
at the root folder of the mobile computer.
4 In the Java Settings screen, choose the Libraries tab and click Add External
Jars. The JAR Selection dialog box appears. Browse to the lib subfolder of the
Java Wireless Toolkit installation folder.
The JARs and class folders on the build path list in the Libraries tab now
includes the JARs you selected.
2 In the Project Name field, enter StockQuote and click Create Project. The API
Selection dialog box appears.
If the stub classes are successfully imported, they are included under the src folder of
the StockQuoteWTK project node.
/**
* Simple class to test the web services stub generated by Sun Java
* Wireless Toolkit 2.5.2.
*/
public class StockQuoteMain {
/**
* @param args
*/
public static void main(String[] args)
{
String sSymbol = null; // Stock symbol
if (args.length > 0)
{
sSymbol = args[0];
}
else
{
sSymbol = "IN"; // Default to Intermec symbol.
}
try
{
System.out.println("Making web services call...");
StockQuoteSoap_Stub stub = new StockQuoteSoap_Stub();
String sQuoteXML = stub.getQuote(sSymbol);
System.out.println("sQuote=" + sQuoteXML);
// Get the value between <Last> and </Last>
int indStart = sQuoteXML.indexOf("<Last>");
int indEnd = sQuoteXML.indexOf("</Last>");
if (indStart >= 0 && indEnd >= 0)
{
String sLatestValue = sQuoteXML.substring(
indStart+6, indEnd);
System.out.println("Quote=" + sLatestValue);
}
else
{
System.out.println("Missing <Last> tag in response");
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
3 In the JAR File Specification screen, click Browse. The Save As dialog box
appears.
5 The JAR file list in the JAR File Specification screen now shows
“StockQuoteWTK/StockQuoteWTK.jar”. This specifies that the output JAR file,
StockQuoteWTK.jar, will be created under the StockQuoteWTK project folder.
5 In the Select Platform screen, select pJSCP V4.12 B142.190307 from the Java
Platform drop-down list and then click Finish.
Copy the following code to the StockQuoteMain Java class and click to save it.
package stockquote;
try
{
System.out.println("Making web services call...");
StockQuote_Stub stub = new StockQuote_Stub();
Programming Notes
The stock symbol is passed in as the first program argument. The default is “IN” if
not specified. It calls the StockQuote_Stub.getQuote method to get the current
quote. Note that this method returns an XML string. You can use the kXML library
to parse the XML. The code uses methods in String to retrieve the value between the
<Last> and </Last> tags.
CrE-ME or CrEme
CrE-ME or CrEme (by NSIcom) is a Java runtime environment for mobile
computers. CrE-ME version 4 implements Java ME CDC Personal Profile 1.0.
Personal Profile
Personal Profile is a specification that defines a profile to extend the Java ME CDC.
It has full AWT 1.1 support and includes all the APIs in the other CDC profiles,
Foundation Profile and Personal Basis Profile.