Four types of royalty-free developer license with lifelong to use
Java Barcode is a Java barcode generator library that produces and prints standard Code 128 and over 20 linear and 2D barcodes in Java applications.
The free evaluation version of the Java Barcode library includes a compiled Java barcode library (single JAR file) for creating and printing Code 128 and other linear and 2D barcodes in Java projects.
Java Code-128 Introduction
Code-128 is also known as ANSI/AIM 128, ANSI/AIM Code 128, USS Code 128, Uniform Symbology Specification Code 128, Code 128 Code Set A, Code 128 Code Set B, Code 128 Code Set C, Code 128A, Code 128B, Code 128C.
Compatibility: Barcode for Java library is compatible with the latest Code-128 ISO specification [ISO/IEC 15417 (Second edition 2007-06-01)].
Code 128 is a very effective, high-density symbology which permits the encoding of alphanumeric data. The symbology includes a checksum digit for verification, and the bar code may also be verified character-by-character verifying the parity of each data byte. This symbology has been widely implemented in many applications where a relatively large amount of data must be encoded in a relatively small amount of space. It's specific structure also allows numeric data to be encoded at, effectively, double-density.
Code 128 Code Sets
Code Set A (or Chars Set A) includes all of the standard upper case U.S. alphanumeric keyboard characters and punctuation characters together with the control characters, (i.e. characters with ASCII values from 0 to 95 inclusive), and seven special characters.
Code Set B (or Chars Set B) includes all of the standard upper case alphanumeric keyboard characters and punctuation characters together with the lower case alphabetic characters (i.e. characters with ASCII values from 32 to 127 inclusive), and seven special characters.
Code Set C (or Chars Set C) includes the set of 100 digit pairs from 00 to 99 inclusive, as well as three special characters. This allows numeric data to be encoded as two data digits per symbol character, at effectively twice the density of standard data.
Code 128 Special characters
The last seven characters of Code Sets A and B (character values 96 - 102) and the last three characters of Code Set C (character values 100 - 102) are special non-data characters with no ASCII character equivalents, which have particular significance to the bar code reading device.
Sample of a Code 128 Barcode
Java Code-128 Encoding Data Scope
Code 128 Barcode for Java supports:
all 128 characters of ASCII.
values 128-255 in accordance with ISO 8859-1. There are referred to as extended ASCII.
How to Generate Code-128 Barcode in Java Class?
The following Java code illustrates how to create a Code-128 barcode, and output to various formats.
1 Linear linear = new Linear(); 2 linear.setType(Linear.CODE128); 3 linear.setData("Code-128"); 4 linear.renderBarcode("c:/barcode.gif");
Set Linear object barcode type to Code-128 (line 2)
Set Code-128 barcode data to encode (line 3)
Encode generated Code-128 barcode into gif image file (line 4)
Generate Code-128 and output to BufferedImage object (line 5)
Generate Code-128 in bitmap and output to byte[] (line 6)
Generate Code-128 and draw to defined area (Rectangle2D) on Graphics2D (line 7-9)
Generate Code-128 and output to OutputStream (line 10-11)
Print Code 128 in Memory
The BarcodeLib Java Barcode library provides several methods to encode and print Code 128 barcodes to various Java objects, allowing further processing directly in your Java program.
Output to an image file path
Output to a Java BufferedImage object
Output to a Java Graphics2D object within a specified rectangle area
Output to a stream object
Output to a byte array
Create Code 128 in Memory and Output to a Java BufferedImage Object
java.awt.image.BufferedImage drawBarcode()
Create Code 128 and Print Barcode in a Specified Area of a Java Graphics2D Object
void drawBarcode(java.awt.Graphics2D g, java.awt.geom.Rectangle2D rectangle)
Create Code 128 and Print Barcode to a Stream Object
boolean drawBarcode(java.io.OutputStream outputStream)
Create Code 128 and Print Barcode to a Byte Array
byte[] drawBarcodeToBytes()
Code 128 Encoding Character Set
Supported Character Set
Code 128 barcodes support the following data characters:
All 128 full ASCII characters defined in ISO/IEC 646
Extended ASCII characters (values 128–255 of ISO/IEC 8859 1, Latin Alphabet 1) via Function Character FNC4
Special characters: 4 non data function characters, 4 code set selection characters, 3 start characters, and 1 stop character
To encode text in Code 128, call the setData() method in the Java class using the Java Barcode Generator library.
Code 128 Code Sets
To encode data efficiently, the Code 128 standard specifies three code sets for converting data to codewords.
Code Set A: Includes all standard uppercase alphanumeric characters, punctuation characters, and control characters.
Code Set B: Includes all standard uppercase alphanumeric characters, punctuation characters, lowercase alphabetic characters, and seven special characters.
Code Set C: Includes the set of 100 digit pairs from 00 to 99 inclusive, as well as three special characters.
It is recommended to use the auto code set selection provided by the Java barcode library.
How to Set Generated Code 128 Barcode Image Width and Height
You can set the barcode image dimensions using the barcodeWidth and barcodeHeight properties, or by specifying the X (bar module width) and Y (bar module height) values.
How to Generate Barcode Code-128 Image in Java Web Applications?
There are two methods to create Code-128 barcode images in your Java web applications.
The simplest way is to stream barcode image using our buildin barcode servlet application.
Under java_barcode_trial package, copy barcode folder to your java servlet container like tomcat.
Restart tomcat. Now you have installed successfully.
To test your installation, open your web browser and navigate to: http://YourDomain:Port/barcode/linear?Data=123456789&Type=CODE128
To create barcode image in your JSP or html page, you need pass the url to IMG tag src value. For example, <img src="http://YourDomain:Port/barcode/linear?Data=123456789&Type=CODE128" /> Using this method, it will not generate any barcode images in your server side.
The second method is to generate barcode images in your server side.
Create a barcode image in server side, like Linear linear = new Linear(); linear.setData("123456789"); linear.setType(Linear.CODE128); linear.renderBarcode("C:/Tools/Tomcat 5.5/webapps/YourWebApp/barcode-images/barcode.gif");
In your JSP or HTML page, you need use IMG tag to display generated image, like <img src="http://YourDomain:Port/YourWebApp/barcode-images/barcode.gif" />
How to Generate Barcode Code 128 Image in Jasper Reports, iReport, Eclipse BIRT?