Professional Documents
Culture Documents
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.
ii
Contents
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 Developing Java Applications for Intermec Computers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 About the Java Runtime Environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 Java Platform Micro Edition (Java ME) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 Java ME Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 Connected Device Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 Java ME External Links. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 JVMs Based on Java ME CDC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 About the IBM WebSphere Everyplace Micro Environment. . . . . . . . . . . . . . . . . . . .9 About NSIcom CrE-ME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 About the Integrated Development Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10 Using the Eclipse IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Creating A HelloWorld Java Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Setting Project Compiling Source Level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12 Creating A HelloWorld Java Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12 Coding the HelloWorld Java Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13 Exporting to HelloWorld.jar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14 About the JAR Warning Export Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Deploying the HelloWorld Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Using the NetBeans IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18 Installing the Java ME Plug-in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 Installing a CDC Emulator Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 Creating a HelloWorld Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22 Creating a HelloWorld Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 Coding the HelloWorld Java Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 Building the HelloWorld Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25 Running HelloWorld in Emulator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25 Deploying the HelloWorld Application to CrE-ME . . . . . . . . . . . . . . . . . . . . . . . . . .27 Deploying the HelloWorld Application to WEME . . . . . . . . . . . . . . . . . . . . . . . . . . .28 Deploying Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 Creating the Application Shortcut File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 Copying Files to the Mobile Computer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 Running the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30 Remote Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30 Creating a Shortcut for Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 Deploying and Starting a Debug Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 Remote Debugging in Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32 Setting Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32 Setting and Starting the IDE Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32
iii
Contents
Remote Debugging in NetBeans. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34 Setting Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34 Setting and Starting IDE Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35 Accessing Databases Using JDBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37 JDBC Sample Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37 Building the Sample. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38 Running the Sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38 Adapting the Sample for Other DBMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39 Developing a Web Services Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40 Developing a Web Services Client in Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40 Creating a StockQuoteWTK Java Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41 Setting the Project Compiling Source Level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44 Generating Web Services Stubs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44 Importing Generated Stub Classes to Eclipse. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47 Creating a Java Class to Call the Web Services API . . . . . . . . . . . . . . . . . . . . . . . . . . .49 Exporting Classes to StockQuoteWTK.jar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51 Deploying the Web Services Client to the Mobile Computer . . . . . . . . . . . . . . . . . .53 Developing a Web Services Client in NetBeans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .54 Creating the StockQuoteWTK Java Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55 Adding Web Services JAR Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57 Generating Web Services Stubs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58 Creating a Java Class to Call the Web Services API . . . . . . . . . . . . . . . . . . . . . . . . . . .59 Building the StockQuoteWTK Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60 Deploying StockQuoteWTK onto Mobile Computer. . . . . . . . . . . . . . . . . . . . . . . . .60 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62
iv
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.
vi
Optional Packages a set of technology-specific APIs that extends the functionality of a Java application environment. Optional packages must be used in conjunction with a configuration or a profile.
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.
Its default and preferred graphics library is based on the Truffle implementation of AWT. The look and feel are different from standard AWT. The major drawback of CrE-ME is its Java Native Interface (JNI) implementation. The JNI invocation would block the VM operation. If a JNI method is called from a thread in a Java application, all threads in the application are blocked until the JNI call returns.
There are two ways to prevent a blocking JNI call from blocking the entire application. The easiest way is to specify the -noblock VM option in the command line you use to start your application. The preferred way recommended by NSIcom is to call the creme.Noblock.on method before the JNI call, and creme.Noblock.off method after the JNI call. Because of CrE-MEs JNI implementation, some IDL Java classes (such as BarcodeReader and Imager) will not work properly. It is not desirable to add CrEME specific library calls in the IDL libraries. Therefore, Intermec recommends that you specify the -noblock VM option in the application shortcut if you use the aforementioned IDL Java classes. For more on application shortcuts, see Creating the Application Shortcut File on page 29.
10
11
3 Click Finish. Note: The Create new project in workspace button specifies that the project folder will be created under the default Eclipse workspace directory.
6 Click OK.
12
5 Click Finish.
13
{ dispose(); System.exit(0); } }); } public static void main(String[] args) { HelloWorld hwApp = new HelloWorld("Hello World"); hwApp.setSize(200, 200); hwApp.setVisible(true); } }
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.
14
4 Browse to the HelloWorld project folder, enter HelloWorld.jar in the File name field, and then click Save.
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.
15
5 Click Next twice. The JAR Manifest Specification screen appears. 6 Click Browse. The Select Main Class dialog box appears.
7 Select HelloWorld from the list and click OK. In the JAR Manifest Specification screen, sample.HelloWorld appears in the Main class field.
16
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).
17
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.
18
19
5 In the Add Java Platform dialog box, select Java ME CDC Platform Emulator and click Next.
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.
20
A new platform entry is added to the CDC node in the Java Platform Manager dialog box.
21
3 In the Name and Location screen: a In the Project Name field, enter HelloWorld. b In the Project Location field, enter the path to (or browse to) the project location, or accept the default location. c Uncheck the Create Main Class check box. d Click Next.
22
4 In the Select Platform section, choose pJSCP V4.12 B142.190307 from the Java Platform list and then click Finish.
23
24
public void actionPerformed(ActionEvent e) { dispose(); System.exit(0); } }); } public static void main(String[] args) { HelloWorld hwApp = new HelloWorld("Hello World"); hwApp.setSize(200, 200); hwApp.setVisible(true); } }
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.
25
4 Choose sample.HelloWorld from the list box and then click Select Main Class.
5 In the HelloWorld properties dialog box, make sure that sample.HelloWorld appears in the Main Class field of the CDC Run tab.
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.
26
27
5 Check the Run in remote VM check box. 6 By default, the application JAR file (HelloWorld.jar) is deployed to the \My Documents\NetBeans Applications folder on the mobile computer. To deploy the application to a different location, change information in the Application Location field. 7 Click OK. 8 In the Projects window, right-click the HelloWorld project and choose Run from the popup menu. NetBeans builds and deploys the HelloWorld.jar to the mobile computer and runs the application. The HelloWorld UI appears on your mobile computer.
28
Deploying Applications
Deploying your Java application to Intermec mobile computer generally involves copying the application JAR files and the application shortcut file to the mobile computer.
The command line you specify in the shortcut file depends on the JVM. Generally, you should specify the VM executable followed by the VM options and classpath, the application main class name, and application arguments. Using the HelloWorld example we created earlier, the shortcut file should look like the following: HelloWorld-WEME6-PPRO11.lnk for WEME 6.2 Personal Profile 1.1
255#"\J9\PPRO11\bin\j9.exe" "-jcl:ppro11" "-classpath" "\Program Files\HelloWorld\HelloWorld.jar" "sample.HelloWorld"
Note: Although you may see multiple lines in the above examples, there is only one line of text in the shortcut file. For more information regarding the specific VM options, refer to your JVM documentation.
29
Note: The file path must match the classpath you specified in the shortcut file. You may copy the shortcut file anywhere on the device. For ease of maintenance, place the shortcut file in the same folder as the application JAR files.
Tip: If you get java.lang.NoClassDefFoundError exception when you run the application, double-check the classpath and the main class name you specified in the shortcut. Make sure the JAR files exist in the specified location on the mobile computer.
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.
30
Note the italicized debug options. The following explains the settings specified in the Xrunjdwp option. The IDE debugger settings need to match these settings. The transport=dt_socket setting specifies the debugger connection will be made via JPDA socket transport. The server=y setting specifies the VM will wait for the remote debugger (IDE) to attach at the port number specified in the address setting. The address=8000 setting specifies the port number (8000) on which the VM is waiting for the remote debugger (IDE) to attach.
31
The application does not start until the remote debugger attaches. The next sections explain how to attach to the debug session from the Eclipse or NetBeans IDE.
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.
32
10 Click Apply to save the settings, or click Debug to save the settings and start debugging.
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.
33
As seen in the following screenshot, the debugger 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.
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.
34
35
As soon as the debugger attaches to the remote VM, the application runs. On the mobile computer, WEME (J9) launches the HelloWorld UI, unless there are breakpoints before the UI is displayed.
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.
36
37
while (rs.next()) { System.out.print("ITEM=" + rs.getString(1) + ", "); System.out.println("QTY=" + rs.getInt(2)); } // Since this is only an example, delete the INVENTORY table. st.executeUpdate("Drop table INVENTORY"); System.out.println("*** Deleted table: INVENTORY"); } catch (Exception e) { e.printStackTrace(); } finally { // Releases resources. try { if (rs != null) rs.close(); } catch (Exception e) {e.printStackTrace();} try { if (st!= null) st.close(); } catch (Exception e) {e.printStackTrace();} try { if (con != null) con.close(); } catch (Exception e) {e.printStackTrace();} } } }
Note that it specifies the -Djava.library.path=\Windows option which is required in order for WEME to load the DB2es native DLLs. This shortcut assumes the JDBCSample.class is packaged in JDBCSample.jar which is located in the \Program Files\JDBCSample folder on the mobile computer.
38
This sample application simply outputs to the console. The J9 console displays the following text when you run the application.
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.
It instantiates the oracle.lite.poljdbc.POLJDBCDataSource object and sets up the data source url jdbc:polite:polite. It also sets the username and password to access the database. Once you made these changes, the rest of the code in JDBCSample should work fine with the Oracle Lite database.
39
40
The following is a summary of the development process. 1 Create an Eclipse Java project and add the web services JAR files from the Java Wireless Toolkit as external JARs. 2 Adjust the project compiling source level. 3 Use the Sun Java Wireless Toolkit to generate the web services stubs. 4 Import the generated stubs to the Eclipse project. 5 Create a Java class to call the web services API via the stub. 6 Export the application class files to a JAR. 7 Deploy the application to an Intermec mobile computer.
41
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.
42
The JARs and class folders on the build path list in the Libraries tab now includes the JARs you selected.
43
44
To generate the web services stubs 1 Click New Project. The New Project dialog box appears.
2 In the Project Name field, enter StockQuote and click Create Project. The API Selection dialog box appears.
45
3 Click OK. 4 In the menu bar, choose Project > Stub Generator.
5 In the Stub Generator Dialog, do the following: a In the WSDL Filename or URL field, enter http:// www.webservicex.net/stockquote.asmx?wsdl. b In the Output Package field, enter test.stub. This field specifies the package name that the stub classes will be generated under. c Click OK. Note: When the stub generation is successfully completed, the generated Java classes appear in the indicated Output Path.
46
6 Locate the generated Java classes. We will import these classes to Eclipse later.
47
3 In the File system screen: a Click Browse and browse to the folder where the stubs were generated. This example selects the src folder that contains the test\stub subfolder. Make sure the src checkbox is checked. b In the Into folder entry field, type StockQuoteWTK\src. c Click Finish.
If the stub classes are successfully imported, they are included under the src folder of the StockQuoteWTK project node.
48
49
to
50
Programming Notes
The stock symbol is passed in as the first program argument. The default is IN if not specified. It calls the StockQuoteSoap_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 above code uses methods in String to retrieve the value between the <Last> and </Last> tags.
3 In the JAR File Specification screen, click Browse. The Save As dialog box appears.
51
4 Browse to the StockQuoteWTK project folder, enter StockQuoteWTK.jar in the File name field, and click Save.
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.
52
53
5 In the ActiveSync window, click Explore and browse to the \StockQuoteWTK folder, where you should see the following files:
6 On the Intermec mobile computer, use File Explorer to browse to the \StockQuoteWTK folder. 7 To run the application with WEME, tap the shortcut StockQuoteWTK-WEME6PPRO11.lnk (with the purple WebSphere icon next to it). The stock quote value is displayed in the J9 Console.
To run the application with CrE-ME 4, tap the shortcut StockQuoteWTKCrEME4.lnk. The result will be outputted to jscpout.txt located at the root folder of your mobile computer. Note: It may take several minutes for the web services call to return a response when running in CrE-ME 4.
54
The Java ME plugin for NetBeans 6.8 includes Java ME SDK 3.0. As noted in the beginning of Developing a Web Services Client, the jsr172_1.0.jar file in Java ME SDK does not work in CDC. Therefore, we will use the plug-in only to generate the stubs. At runtime, we will use the JAR files in Java Wireless Toolkit 2.5.2. If you have not already installed Java Wireless Toolkit, download and install sun_java_wireless_toolkit-2.5.2_01-win.exe from the Sun Java Wireless Toolkit 2.5.2_01 for CLDC Download web site. The following is a summary of the development process. 1 Create a NetBeans Java project. 2 Add web services JAR files from the Java Wireless Toolkit as external JARs. 3 Generate the web services stubs. 4 Create a Java class to call the web services API via the generated stub. 5 Build the application. 6 Deploy the application to an Intermec mobile computer.
55
4 In the Name and Location screen: a In the Project Name field, enter StockQuoteWTK. b In the Project Location field, enter the path to the project location, or click Browse to browse to the project location. To accept the default location, continue with the next step. c Uncheck the Create Main Class checkbox. d Click Next.
5 In the Select Platform screen, select pJSCP V4.12 B142.190307 from the Java Platform drop-down list and then click Finish.
56
57
6 The Libraries and Resources list in the StockQuoteWTK project settings screen now includes the JAR files you added.
58
Two Java classes, StockQuote.java and StockQuote_Stub.java, are generated with the package name stockquote.
Copy the following code to the StockQuoteMain Java class and click
package stockquote; public class StockQuoteMain { 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 {
to save it.
59
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(); } } }
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.
60
To run the application with CrE-ME 4, tap on the shortcut StockQuoteWTKCrEME4.lnk. The result is sent to jscpout.txt located at the root folder of your mobile computer. Note: It may take several minutes for the web services call to return a response when running in CrE-ME 4.
61
Glossary
AWT (Abstract Window Toolkit)
AWT provides a basic set of graphical user interface (GUI) components that were implemented using native-platform versions of the components.
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.
62
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.
63
Worldwide Headquarters 6001 36th Avenue West Everett, Washington 98203 U.S.A. tel 425.348.2600 fax 425.355.9551 www.intermec.com 2010 Intermec Technologies Corporation. All rights reserved.