Aspose.BarCode  for Java

Read UPC Barcodes with Java

Read UPC (Universal Product Code) barcode in Java using server-side Aspose.BarCode for Java API

How to Read UPC (Universal Product Code) barcode Using Java

To recognize UPC (Universal Product Code) barcode, use Aspose.BarCode for Java API, an advance, robust, and easy-to-use barcode library for Java-based platforms. Download the latest version directly from Maven and install it within your Maven-based projects by including the following configurations in pom.xml:


    <name>Aspose Java API</name>


    <version>version of aspose-barcode API</version>

Steps for Scanning UPC (Universal Product Code) barcode in Java

Aspose.BarCode allows developers to read UPC (Universal Product Code) barcode barcodes from stream or image with few lines of code

  • Create a new object of BarCodeReader class
  • Set the source file path containing UPC (Universal Product Code) barcode
  • Pass the required barcode types to DecodeType as the second parameter
  • Loop through the decoding results
  • Get barcode text using the getCodeText method

System Requirements

Aspose APIs are supported on all major platforms and operating systems. Before executing the code sample below, please make sure that your system comply with the following requirements.

  • Microsoft Windows, Linux, or any OS compatible with Java Runtime Environment for JSP/JSF and desktop applications
  • Java development environment, such as JRE 1.6 or above
  • Java Development version JSE2 7.0 or above
Ready to recognize Recognizing Drop a file here or click to browse *

* By uploading your files or using the service you agree with our Terms of use and Privacy Policy.

Code to be executed - Java

// initialize reader with image & expected type
BarCodeReader reader = new BarCodeReader(var reader = new Aspose.BarCode.BarCodeReader("<file name>", DecodeType.UPC);

// read code
while ( {
    // print the code type & text
    System.out.println("Type: " + reader.getCodeType() + " Text: " + reader.getCodeText());

Recognition result