Home  >  Java Barcode  >  Java Barcode Generation Guide  >  Java Code 128 Barcode Generator | Generate Code 128 Barcode in Java Class
Java Code-128 Barcode Generator
This professional Java Code 128 barcode generator supports barcode Code-128 generation in Java Class, Jasper Reports, iReport and BIRT.
Java Code-128 Barcode 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 and Code 128C.
Code 128 is a very effective, high-density symbology which permits the encoding of alphanumeric data. This symbology includes a checksum digit for verification, and the bar code may also be verified character-by-character to verify the parity of each data byte.

This linear barcode 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. Its specific structure also allows numeric data to be encoded at, effectively, double-density.
Java Barcode Code 128 Generator - Generate Barcode Code-128 in Java Class
The following Java code can help Java developers generate & create Code 128 barcode in Java class.
BarCode barcode = new BarCode(); 

// set Code 128 barcode properties
barcode.setSymbologyType(BarCode.CODE128);
barcode.setCodeText("CODE128");

// draw and generate barcode to buffered image object
BufferedImage code128Image = barcode.drawBarCode2Image();
Java Barcode Code 128 Generator - Generate Code-128 Barcode Image in Java Servlet Applicaton
Using this Java Code 128 barcoding control, you can easily & quickly integrate Code 128 barcode generating functions into your Java Servlet class project.
public class BarcodeServlet extends HttpServlet 
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException
{
try
{
BarCode barcode = new BarCode();

// set barcode properties
barcode.setSymbologyType(BarCode.CODE128);
barcode.setCodeText("CODE128");

// draw and generate barcode to response's ServletOutputStream
ServletOutputStream servletoutputstream = response.getOutputStream();

barcode.drawBarCode2Stream(servletoutputstream);
}

catch (Exception e)
{
throw new ServletException(e);
}
}
}
Java Barcode Code 128 Generator - Create Code-128 Barcode Through HTTP Request
  1. Install Java Barcode Generator Servlet application to Tomcat or JBoss. Java developers need to copy barcode folder to your Tomcat application folder, and restart the Tomcat.
  2. After Tomcat restarted, open your web browser and navigate to:
    http://your_tomcat_url:port/barcode/barCode?code-text=CODE128&symbology-type=8
  3. You can also insert Code 128 barcode image in HTML or JSP page.
    <img src="http://your_tomcat_url:port/barcode/barCode?code-text=CODE128&symbology-type=8">
Java Barcode Code 128 Generator - Draw & Print Barcode Code-128 in java.awt.Image Object
The following Java source code shows how to generate a Code 128 barcode in a java.awt.Image object.
private static void demoLinearBarcode() throws Exception 
{
BarCode barcode = new BarCode();

// set barcode properties
barcode.setSymbologyType(BarCode.CODE128);
barcode.setCodeText("CODE128");

// create image object
java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(300,300,java.awt.image.BufferedImage.TYPE_BYTE_INDEXED );

// get graphic context of image
java.awt.Graphics2D imgGraphics = image.createGraphics();

// draw barcode to specified location in Rectangle
barcode.paintBarCode(imgGraphics, new java.awt.Rectangle(0, 0, 300, 300));
}
Java Code-128 Barcode Properties
Code-128 Type Value: com.keepdynamic.barcode.generator.BarCode.CODE128 (8).

Code-128A Type Value: com.keepdynamic.barcode.generator.BarCode.CODE128A (9).

Code-128B Type Value: com.keepdynamic.barcode.generator.BarCode.CODE128B (10).

Code-128C Type Value: com.keepdynamic.barcode.generator.BarCode.CODE128C (11).
Java Barcode Code 128 Generator - Generate Other Barcode Types in Java Project