Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Okapi Barcode License Maven Central Build Status Code Coverage

Okapi Barcode is an open-source barcode generator written entirely in Java, supporting over 50 encoding standards, including all ISO standards. Okapi Barcode is based on Zint, an open-source barcode encoding library developed in C, and builds on the years of work that have been invested in that project.

Supported Symbologies

Library Usage

To generate barcode images in your own code using the Okapi Barcode library, use one of the symbology classes linked above:

  1. instantiate the class,
  2. customize any relevant settings,
  3. invoke setContent(String), and then
  4. pass the symbol instance to one of the available symbol renderers (Java 2D, PostScript, SVG)
Code128 barcode = new Code128();

int width = barcode.getWidth();
int height = barcode.getHeight();

BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
Graphics2D g2d = image.createGraphics();
Java2DRenderer renderer = new Java2DRenderer(g2d, 1, Color.WHITE, Color.BLACK);

ImageIO.write(image, "png", new File("code128.png"));

Okapi Barcode JARs are available for download from Maven Central.

GUI Usage

To use the Swing GUI, just run the OkapiUI class. The GUI allows you to explore the supported barcode symbologies and test them with different configurations and data.

Okapi GUI Screenshot


gradlew check: Compiles and runs all quality checks, including the unit tests.
gradlew jar: Builds the JAR file.
gradlew uploadArchives: Deploys to Maven Central (requires a modified file).

NOTE: The unit tests should all pass under Oracle JDK, but will probably not all pass under OpenJDK. The tests verify barcode rendering image output, and the output images generated by OpenJDK are a bit different from the output images generated by the Oracle JDK (because their 2D graphics and font subsystems are slightly different).

Recent Releases

Okapi Barcode 0.3.3

  • GS1 Composite: avoid ArrayIndexOutOfBoundsException in some rare corner cases
  • PDF417: add setContent(byte[]) method for binary data
  • PDF417: when using structured append (Macro PDF417), place padding before control block rather than after
  • PDF417: fix auto-calculation of row count when data is very small and column count is specified
  • PDF417: add support for segment count and file name Macro PDF417 optional fields
  • Royal Mail 4-State: fix bug in check digit calculation

Okapi Barcode 0.3.2

  • MSI Plessey: allow empty content
  • MSI Plessey: improve symbol configurability (module width ratio, check digit visibility)
  • Add support for the original Plessey symbology (also known as UK Plessey)

Okapi Barcode 0.3.1

  • Improve build times
  • Code 128: allow empty content
  • All GS1 symbols: improve GS1 AI validations
  • Data Matrix: allow use of GS as the GS1 separator
  • Data Matrix: fix data too long to fit in symbol issue
  • Data Matrix: add trailing data characters to debug logs

Okapi Barcode 0.3.0

  • POSTNET: improve symbol configurability (module width ratio, short height percentage, long height percentage)
  • USPS OneCode: improve symbol configurability (module width ratio, short height percentage, long height percentage)


Open-source barcode encoding program written in Java







No packages published