Barcode4J is a flexible generator for barcodes written in Java. This is a modernized fork maintained by Ribose for the Metanorma project.
Original website: http://barcode4j.sourceforge.net
This fork modernizes the original Barcode4J library with:
-
Modern Java support: Updated to Java 8+ with testing on JDK 8, 11, 17, and 21
-
Maven-first: Fully Maven-based build system with modern plugins
-
CI/CD pipeline: Comprehensive GitHub Actions workflow testing on Ubuntu, Windows, and macOS
-
Updated dependencies: All dependencies updated to latest stable versions
-
Code quality: Integrated Checkstyle, SpotBugs, and OWASP dependency checking
-
Security: Regular vulnerability scanning and dependency updates
-
UTF-8 encoding: Modern character encoding throughout
Barcode4J supports generation of the following barcode formats:
-
Code 39 (3 of 9)
-
Code 128 (including GS1-128/EAN-128)
-
Codabar (2 of 7)
-
Interleaved 2 of 5 (ITF-14)
-
UPC-A and UPC-E
-
EAN-13 and EAN-8
-
POSTNET and Royal Mail CBC
-
USPS Intelligent Mail
import org.krysalis.barcode4j.impl.code128.Code128Bean;
import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;
// Create barcode bean
Code128Bean bean = new Code128Bean();
bean.setModuleWidth(0.21);
bean.setBarHeight(10.0);
// Generate barcode
BitmapCanvasProvider canvas = new BitmapCanvasProvider(
300, BufferedImage.TYPE_BYTE_BINARY, false, 0);
bean.generateBarcode(canvas, "Hello World");
canvas.finish();
// Get the generated image
BufferedImage image = canvas.getBufferedImage();This project uses several tools to maintain code quality:
-
Checkstyle: Code style checking
-
SpotBugs: Static analysis for bugs
-
JaCoCo: Code coverage reporting
-
OWASP Dependency Check: Security vulnerability scanning
Run quality checks:
mvn clean compile -PqualityThe project includes comprehensive test suites:
-
Unit tests using JUnit 5
-
Integration tests
-
Cross-platform testing on Ubuntu, Windows, and macOS
-
Multi-JDK testing (Java 8, 11, 17, 21)
Update version in pom.xml:
<groupId>org.metanorma</groupId>
<artifactId>barcode4j</artifactId>
<version>2.4.0</version>