Compiling and Running the TSP100 Series JavaPOS Sample Application Note Introduction

Application Note
Compiling and Running the TSP100 Series JavaPOS Sample
Introduction
This application note shows how to compile and run the JavaPOS sample provided on the TSP100 Installation CD. These
directions were written using a TSP100ECO but are applicable for all models listed below.
Supported Printers: TSP100ECO, TSP100USB, TSP100PUSB, TSP100LAN, TSP100GT
Supported Interfaces: USB, PoweredUSB, Ethernet
Supported Environments: Windows 7 (32/64-bit), Windows Vista (32/64-bit), Windows XP
Star Tools Needed: futurePRNT Configuration Utility 5.2 or higher found on the Installation CD
Table of Contents
I. futurePRNT and Printer Installation ……………………………………. Page 1
II. Assigning a JavaPOS Device Name …………………………………….. Page 2
III. Running the JavaPOS Sample ……………………………………………. Page 7
IV. Troubleshooting ……………………………………………………………….. Page 11
I. futurePRNT and Printer Installation
If the futurePRNT Configuration Utility and TSP100 have already been installed on the system, skip to section 2, Assigning a
JavaPOS Device Name.
If these have not been installed on the system, it is necessary to install them using the Installation CD that shipped in the
box with the TSP100 at this point in time. If the CD was misplaced, the contents can be downloaded again for free from the
Star Global Support Site.
For detailed installation instructions on futurePRNT and TSP100 installation, choose the printer’s connection interface
below to open the relevant FAQ:
USB / PoweredUSB
Ethernet
Once the printer is installed on the system, return to this application note and skip to section 2, Assigning a JavaPOS Device
Name.
04/2012, V1.0
Page 1
Application Note
II. Assigning a JavaPOS Device Name
1. Click the Windows Start button and navigate All Programs > StarMicronics > Star TSP100 > Configuration Utility.
2. Click “Star Line Mode” and then OK.
3. Click “JavaPOS” in the left menu bar.
04/2012, V1.0
Page 2
Application Note
4. Click “Create JavaPOS XML Registry File”.
5. Browse to the location of the JavaPOSExamples folder installed during futurePRNT’s installation. Then click “Save”.
Important: If the OS is 64-bit, be sure to not save the XML file in the 32-bit folder and likewise. This mismatch can result in
print job failure when running the sample.
64-bit default location: C:\Program Files\StarMicronics\TSP100\Software\20110922\JavaPOSExamples
32-bit default location: C:\Program Files (x86)\StarMicronics\TSP100\Software\20110922\JavaPOSExamples
04/2012, V1.0
Page 3
Application Note
6. Click “Load JavaPOS XML Registry File”.
7. Browse to the location the XML file was saved in step 5. Highlight it and click “Open”.
04/2012, V1.0
Page 4
Application Note
8. Click the “Add New” button in the POSPrinter section.
9. Enter a new JavaPOS device name if desired and click “OK”.
10. Highlight the newly created device and click “Configure”.
04/2012, V1.0
Page 5
Application Note
11. Ensure “Do Checked Block Printing” is checked and click “Accept”.
12. Click “Apply Changes” in the lower right hand corner.
13. Highlight the device name and click “Check Health”.
14. The TSP100 prints a test page and the above message appears indicating the printer has successfully been set up as a
JavaPOS device.
04/2012, V1.0
Page 6
Application Note
III. Running the JavaPOS Sample
1. Browse to the location where the JavaPOS XML file was created in the JavaPOSExamples folder. Again, ensure the file’s
location is located in the 64-bit Program Files directory if the OS is 64-bit, and likewise for a 32-bit OS. Right click the
“jpos.xml” file and click Edit.
2. Find the line that contains JposEntry logicalName=. Highlight the logical name between the quotation marks and copy.
3. Close the file.
04/2012, V1.0
Page 7
Application Note
4. In the JavaPOSExamples folder, open the “StarReceiptTest.java” folder.
5. Search for the words “printer.open”. Highlight “default” between the quotation marks and delete it.
04/2012, V1.0
Page 8
Application Note
6. In place of “default”, paste the logical name copied from the jpos.xml file. This must match exactly, unless
communication cannot occur between the sample program and printer. If the logical device name changes or another
printer model is added, this name needs to be modified in the sample program each time.
7. Open the Windows command prompt.
8. Change to the directory of the JavaPOSExamples folder.
9. Input “javac -classpath jpos113-controls.jar;jcl.jar StarReceiptTest.java” to compile the program.
(Received an error regarding javac? Check out IV Troubleshooting for a possible fix.)
04/2012, V1.0
Page 9
Application Note
10. Input “java -classpath .;starjavapos.jar;stario.jar;jpos113-controls.jar;jcl.jar;xercesimpl.jar;xml-apis.jar StarReceiptTest”
to execute the program.
The TSP100 prints a sample receipt and the above screen confirms successful output.
If the program compiled successfully after inputting the javac line but no printing occurs, check out IV Troubleshooting.
Congratulations! You have successfully added the TSP100 as a JavaPOS device and ran the sample program.
04/2012, V1.0
Page 10
Application Note
IV. Troubleshooting
Issue: “Javac is not recognized as an internal or external command, operable program or batch file."
If this message occurs when attempting to compile the sample program from the command prompt, there are two things to
check:
1. Ensure the latest version of JRE is installed. http://www.oracle.com/technetwork/java/javase/downloads/index.html
2. Ensure the location of the JDK bin file has been added to the System Variables.
3. Start Menu > Right click Computer > Select Properties
4. Click “Advanced system settings”.
04/2012, V1.0
Page 11
Application Note
5. Click the Advanced tab and then “Environment Variables”.
04/2012, V1.0
Page 12
Application Note
6. Highlight “Path” and click “Edit”.
7. Add the location of the JDK bin folder at the end of the list followed by a semicolon.
Important: Be sure to add the location to the end of the list only. Do not delete anything.
8. Click OK and then close the System Properties windows.
9. Compile from the command prompt once again.
04/2012, V1.0
Page 13
Application Note
Issue: “The device communications channel could not be opened."
If the above message occurs when running the sample program, confirm these points:
1. Perform a Check Health test in the futurePRNT Configuration Utility. If this test is successful, it means the printer was
successfully configured as a JavaPOS device. If the test fails, check printer connection cables and ensure the printer is listed
in the Devices and Printers (or Printers and Faxes) folder.
2. Ensure the java.xml and StarSampleReceipt.java files are in the correct directory. In the above example, the sample
program was run from the 32-bit directory on a 64-bit machine.
3. Open StarSampleReceipt.java and ensure the correct logical device name was added after the printer.open command.
04/2012, V1.0
Page 14
Star Micronics Worldwide
Star Micronics is a global leader in the manufacturing of small
printers. We apply over 50 years of knowhow and innovation
to provide elite printing solutions that are rich in stellar
reliability and industry-respected features. Offering a diverse
line of Thermal, Hybrid, Mobile, Kiosk and Impact Dot Matrix
printers, we are obsessed with exceeding the demands of our
valued customers every day.
We have a long history of implementations into Retail, Point
of Sale, Hospitality, Restaurants and Kitchens, Kiosks and
Digital Signage, Gaming and Lottery, ATMs, Ticketing,
Labeling, Salons and Spas, Banking and Credit Unions,
Medical, Law Enforcement, Payment Processing, and more!
High Quality POS Receipts, Interactive Coupons with Triggers,
Logo Printing for Branding, Advanced Drivers for Windows,
Mac and Linux, Complete SDK Packages, Android, iOS,
Blackberry Printing Support, OPOS, JavaPOS, POS for .NET,
Eco-Friendly Paper and Power Savings with Reporting Utility,
ENERGY STAR, MSR Reading, futurePRNT, StarPRNT… How
can Star help you fulfill the needs of your application?
Don’t just settle on hardware that won’t work as hard as you
do. Demand everything from your printer. Demand a Star!
Star Micronics Co., Ltd.
536 Nanatsushinya
Shimizu-ku, Shizuoka 424-0066
Japan
+81-54-347-2163
http://www.star-m.jp/eng/index.htm
Star Micronics America, Inc.
1150 King Georges Post Road
Edison, NJ 08837
USA
1-800-782-7636
+1-732-623-5500
http://www.starmicronics.com
Star Micronics EMEA
Star House
Peregrine Business Park, Gomm Road
High Wycombe, Buckinghamshire HP13 7DL
UK
+44-(0)-1494-471111
http://www.star-emea.com
Star Micronics Southeast Asia Co., Ltd.
Room 2902C. 29th Fl. United Center Bldg.
323 Silom Road, Silom Bangrak, Bangkok 10500
Thailand
+66-2-631-1161 x 2
http://www.starmicronics.co.th/