Java Barcode Generator Tutorial
How to generate, create linear, 2d barcode images in Java Class, JSP Pages,Servlet, and Reports
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
- Under demo package, copy barcode folder and its contents to your tomcat webapps file
- Start tomcat, and navigate to http://YourDomain:Port/barcode/barcode?DATA=0123456789&TYPE=CODE128
- To create bar code images in html or jsp pages, you can insert an image tag (img) into your page.
- 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