Java Barcode Generator Tutorial

How to generate, create linear, 2d barcode images in Java Class, JSP Pages,Servlet, and Reports

Download Java Barcode Generator Free Evaluation
Purchase Java Barcode Generator SDK License

Integration guide to generate linear, 2D barcodes using Java Barcode Generator Library

  • Easy to print, embed bulk barcode images in Jasper Report, Eclipse BIRT and iReport
  • Simple to redistribute Java barcode library with simply a jar file
  • Easy to use with no registration key or activation code required
  • Generating high quality bar code images in GIF, JPEG and Png image formats
  • Completely developed in Java, supporting JDK 1.4.2 and later versions
  • Compatible with latest barcode symbology ISO/IEC Standards or GS1 specifications
  • Mature and reliable Barcode Generator Java Library







Java Barcode is a Java barcode generation library which generates high quality 1D (linear) and 2D (matrix) barcodes.
OnBarcode provides complete Java barcode solutions, such as barcode generator in Java, barcode reader in Java, Java jar library for Java applications, and BIRT Barcode for Eclipse BIRT reports.
How to Install Java Barcode Generator Component?
Top
Java Barcode Generator is developed completely in Java, and it supports JDK 1.4.2 and later versions.
How to Generate Barcodes in Java Class?
Top
Here is the Java sample codes for generating a Code 128 in Java Class, please copy to your project for a test. Developers can call barcode.drawBarcode() method to draw barcode on image file or paint barcode in the memory.
// Select a barcode type to create a Java barcode object 
Code128 barcode = new Code128();

// Set barcode data text to encode
barcode.setData("Barcode-in-Java");

// Set barcode data text to encode
barcode.setX(2);

// Generate barcode & encode into GIF format
barcode.drawBarcode("C://barcode-code128.gif");

// Generate barcode & encode into JPEG format
barcode.drawBarcode("C://barcode-code128.jpg");

// Generate barcode & encode into EPS format
barcode.drawBarcode2EPS("C://barcode-code128.eps");

// Generate barcode & print into Graphics2D object
barcode.drawBarcode("Java Graphics2D object");
How to Generate Barcodes in html or JSP Pages with Tomcat?
Top
  1. Under demo package, copy barcode folder and its contents to your tomcat webapps file
  2. Start tomcat, and navigate to http://YourDomain:Port/barcode/barcode?DATA=0123456789&TYPE=CODE128
  3. To create bar code images in html or jsp pages, you can insert an image tag (img) into your page.
  4. Demo tag: <img src="http://YourDomain:Port/barcode/barcode?DATA=0123456789&TYPE=CODE128" />
How to Create & Print Barcode Image in Java Servlet Class?
Top
import com.onbarcode.barcode.AbstractBarcode;
import com.onbarcode.barcode.Code128;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;

public class BarcodeServlet extends HttpServlet
{
 public void doGet(HttpServletRequest request, HttpServletResponse response)
 throws ServletException
 {
  try {
   Code128 barcode = new Code128();
   barcode.setData("0123456789");

   ServletOutputStream servletoutputstream = response.getOutputStream();

   response.setContentType("image/jpeg");
   response.setHeader("Pragma", "no-cache"); 
   response.setHeader("Cache-Control", "no-cache");
   response.setDateHeader("Expires", 0);
   // Generate Code-128 barcode & output to ServletOutputStream
   barcode.drawBarcode(servletoutputstream);
  }
  catch (Exception e) {
   throw new ServletException(e);
  }
 }
}
How to Generate Barcode Image in Jasper Reports?
Top
This high-quality Java Barcode Generator also supports generating barcode images in Jasper Reports. For detailed generation tutorial, please view Complete Guide for Barcode Generation in Jasper Reports.
How to Generate Barcode Image in iReport?
Top
If you need to generate bulk barcode images in iReport with this Java Barcode Generator, please navigate to the online tutorial here: Complete Guide for Barcode Generation in iReport.
How to Generate Barcode Image in Eclipse BIRT?
Top
OnBarcode Java Barcode Generator also support streaming, printing bulk barcode images in Eclipse BIRT. Click here to view Complete Guide for Barcode Generation in Eclipse BIRT
Java Barcode Generator Supporting Barcode Symbology Types
Top

Barcode for Java - Bar Code Types Generation

OnBarcode is a market-leading provider of barcode imaging generator, reader controls and components for ASP.NET, Windows Forms, WPF, as well Java, Android, iOS (iPhone, iPad) across all major enterprise development platforms. We provides comprehensive tutorials and how-tos for various linear, 2d barcode information, such as C# in ASP.NET, C# .NET, C# Barcode Encoding, C# Barcode Image, VB.NET in ASP.NET, VB.NET Winforms, VB.NET Barcode Encoding. OnBarcode barcode products are supported by RasterEdge ASP.NET Document Viewer, which supports ASP.NET PDF Viewer, ASP.NET MVC Document Viewer, ASP.NET PDF Editor, MVC PDF Viewer. And provide high quality C# Convert PDF to Tiff, C# Convert PDF to Word, C# Convert PDF to HTML, C# Convert PDF to Jpeg images, and their easy and simple documents, like C# PDF SDK, C# extract text from PDF, C# Compress PDF, Print PDF in C# and C# extract image from PDF.
Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.