Barcode Xpress for Java v13.4 - Updated
Samples
Getting Started > Samples

All code samples are located in the "samples" sub-folder of the Barcode Xpress for Java install directory. They are located in the Accusoft/BarcodeXpressJava13-64/samples folder. It also contains the ReadMe.txt file with detailed instructions on how to build and run the samples.

Please refer to the "How to Build and Run Samples" section below for information on building the sample.

Barcode Xpress for Java has the following sample to get you started:

Name Description
ReadBarcodes Recognizes the text in an image(s) and prints results to the console.

How to Build and Run Samples

The commands to compile and run the sample will essentially be the same on both Windows and Linux. The only difference is the punctuation mark used to separate entities on the classpath. Java uses ";" on Windows and ":" on Linux.

Using the Command Line

  1. Navigate to the sample folder.
    For example, for the ReadBarcodes sample use the following command:
    Copy Code
    cd Accusoft/BarcodeXpressJava13-64/samples/ReadBarcodes
    
  2. In the sample folder, compile the sample using one of the following commands:
    Linux
    Copy Code
    javac -cp ".:src/main/java:../../bin/barcodexpressjava-13.4.jar" src/main/java/ReadBarcodes.java
    
    Windows       
    Copy Code
    javac -cp ".;src/main/java;../../bin/barcodexpressjava-13.4.jar" src/main/java/ReadBarcodes.java
    
  3. Run the sample using one of the following commands:
    Linux
    Copy Code
    java -cp ".:src/main/java:../../bin/barcodexpressjava-13.4.jar" ReadBarcodes path/to/your/image.bmp
    
    Windows
    Copy Code
    java -cp ".;src/main/java;../../bin/barcodexpressjava-13.4.jar" ReadBarcodes path/to/your/image.bmp
    

Using Maven

  1. Navigate to the sample folder. For example, for the ReadBarcodes sample use the following command:
    Copy Code
    cd Accusoft/BarcodeXpressJava13-64/samples/ReadBarcodes
    
  2. In the sample folder, run the following command:
    Copy Code
    mvn clean package dependency:copy-dependencies
    
    After the command has successfully completed, the "target" folder will be created in the sample folder.
  3. Run the sample with the following command:
    Linux
    Copy Code
    java -cp "target/ReadBarcodes-1.0.jar:target/dependency/barcodexpressjava-13.4.jar" ReadBarcodes path/to/your/image.bmp
    
    Windows
    Copy Code
    java -cp "target/ReadBarcodes-1.0.jar;target/dependency/barcodexpressjava-13.4.jar" ReadBarcodes path/to/your/image.bmp
    

Running the Sample with Arguments

The ReadBarcodes sample allows you to specify the type of barcode to search. So, if you want to look for only 1D barcodes, only 2D barcodes, or all types of barcodes, use the type option to specify it.

Usage

Copy Code
ReadBarcodes [options] <image1> [<image2> ... <imageN>]

Options

-t, --type <type> (optional = true, default = '1d') Barcode types to scan
<type>: '1d' - all 1D | '2d' - all 2D | 'all' - all 1D + 2D
-h, --help (optional = true) Print this help message

Examples

ReadBarcodes ../images/Barcode-All-Supported-Types.bmp ../images/Barcode-Multiple-Common.bmp
ReadBarcodes -t 2d ../images/Barcode-All-Supported-Types.bmp
ReadBarcodes --type all ../images/Barcode-*

Using an IDE

  1. To get started, open either Netbeans, Eclipse or IntelliJ.
  2. Navigate to the sample folder, open a sample and then compile the project.
    This will unpack all the required Maven dependencies needed to run Barcode Xpress.
  3. You will now be able to edit your sample file.