Java Barcode Data Encoding Tutorial
How to encode GS1-Compatible barcode images & Unicode using Java Class
Create GS1 compatible barcodes and encode Unicode into barcodes for Java programs
- Easy to integrate java barcode library (jar) to encode GS1 barcodes images
- Create GS1-compatible QR Code, Data Matrix, ITF-14, EAN-128, and GS1 Databar in Java
- Compatible with the latest GS1 & ISO / IEC barcode specifications
- Unicode support for easily encoding barcodes with non-English character sets
- Java class sample code provided to ensure valid barcode data input
- Capable of printing & embedding barcodes in Jasper Report, iReport, Eclipse BIRT Report
- API with simple examples to create GS1 barcodes in html JSP pages, Servlet, J2EE web applications
- Mature Java barcode SDK with a variety of developer licenses to select from
Java Barcode Generator is a mature Java Barcode Library SDK (jar files) which enables developers to easily generate over 30 linear & 2D (two-dimensional) barcode types in Java programs, including major GS1, ISO/IEC, postal barcodes. With this Java barcode jar, users can stream barcodes in Java Server Side projects like JSP, Java Servlet, apart from Java Class, Jasper Report, and Eclipse BIRT, Oracle Report. Besides, the intuitive interface provides full features & flexible functions for barcode control & design.
OnBarcode also provides other Java tutorials for barcode implementation:
- Java Barcode Generator Tutorial - How to generate & draw barcode images in Java applications programmatically
- Java Class Barcode Tutorial - How to stream & create barcode graphics in Java Class Library with free barcoder trial download
- Java Servlet Barcode Tutorial - How to create & display barcodes in Java web applications (JSP Servlet) or website
- iReport Barcode Tutorial - How to print & embed barcode image labels in iReport via java programming step by step
How to Encode GS1 Barcodes in Java Class
Top
This Java Barcode Library can encode UPC/EAN Barcodes with GS1 standard pre-configured. Alternatively, if you want to encode GS1-compatible QR Code, Data Matrix, GS1-Databar, GS1-128/EAN-128 or ITF-14, please follow the basic Java class sample code here.
Please note that the checksum character is automatically calculated and added to some linear barcode with obligatory check digit requirement. If you want to reduce barcode size, change barcode value, customize image color / orientation, or switch to another output method, simple add more in the Java barcode syntax below.
To learn how to adjust barcode image formats into GIf / Jpeg (Jpg)/ Png / Tiff, please navigate to
Java Barcode Image Setting TutorialCreate GS1-DataBar Barcode in Java Class
GS1DataBar gs1databar = new GS1DataBar();
//Set GS1-Databar barcode data string - encoding example numbers
gs1databar.setData("11111555551234");
//Adjust barcode size of GS1-Databar
gs1databar.setX(2);
gs1databar.setY(60);
gs1databar.setBarcodeWidth(220);
//Set GS1 DataBar image rotation and display text
gs1databar.setRotate(0);
gs1databar.setShowText(true);
gs1databar.drawBarcode("C://ob-gs1databar.gif");
Create GS1-128/EAN-128 Barcode in Java Class
EAN128 gs1128 = new EAN128();
gs1128.setData("(12)445566");
//Control GS1-128 barcode size with Java coding
gs1128.setUom(0);
gs1128.setX(2);
gs1128.setY(60);
gs1128.setLeftMargin(10);
gs1128.setRightMargin(10);
//Set GS1-128 image orientation and image format into Gif
gs1128.setRotate(0);
gs1128.setImageFormat(1);
gs1128.drawBarcode("C://ob-gs1128.gif");
Create GS1 ITF-14 Barcodes in Java Class
ITF14 itf14 = new ITF14();
itf14.setData("00000555551234");
//Resize ITF-14 barcode image size with Java code
itf14.setUom(0);
itf14.setX(2);
itf14.setY(60);
itf14.setN(2);
//Set ITF-14 bearer bar style as required by GS1 standard
itf14.setBearerBarHori(2);
itf14.setBearerBarVert(2);
itf14.setImageFormat(3);
itf14.drawBarcode("C://ob-itf14.png");
Create GS1-Compatible QR Code in Java Class
QRCode qrcode = new QRCode();
//Select QR Code Data Mode and encoding data
qrcode.setDataMode(0);
qrcode.setData("(01)55678");
//Set QR Code FN1 to enable GS1-compatibility
qrcode.setFnc1Mode(1);
//Adjust QR Code barcode size through module and quiet zone
qrcode.setX(2);
qrcode.setLeftMargin(8);
qrcode.setRightMargin(8);
qrcode.setTopMargin(8);
qrcode.setBottomMargin(8);
//Set barcode image format, resolution and then generate it
qrcode.setImageFormat(1);
qrcode.setResolution(96);
qrcode.drawBarcode("C://java-qrcode.gif");
Create GS1-Compatible Data Matrix in Java Class
DataMatrix datamatrix = new DataMatrix();
datamatrix.setDataMode(0);
datamatrix.setData("456789");
//Select FNC1 Mode to encode GS1-compatible Data Matrix
datamatrix.setFnc1Mode(1);
//Resize Data Matrix barcode image
datamatrix.setFormatMode(4);
datamatrix.setX(3);
datamatrix.setTopMargin(3);
datamatrix.setBottomMargin(3);
datamatrix.setLeftMargin(3);
datamatrix.setRightMargin(3);
datamatrix.drawBarcode("C://java-datamatrix.gif");
How to Encode Unicode into Barcodes in Java Class
Top
The ISO/IEC 8859-1 standard character set is used in various barcode types, as it covers a wide range of characters in English, French, Italian, Spanish, etc. However, if you want to encode data from other character sets, such as Arabic, Chinese, Japenese and Greek, you can simply convert the special char to Unicode encoding first, and then encode it in QR Code, Data Matrix or PDF-417.
Below is the Java demo code for 2D barcodes generation & encryption, in which UTF-8 encoding is applied to convert the original data to Unicode. Please note that the decoded data need to be converted back so you can get your original data for the barcode image.
Encode Unicode into QR Code in Java Class
Encode Unicode into Data Matrix in Java Class
Encode Unicode into PDF-417 in Java Class
Java Barcode Generation Guide for Linear & 2D Barcode Types
Top
Java Barcode Library SDK - Barcodes Generation