Java Barcode Generator Online Tutorial

How to Create, Draw, Generate, Print Linear & 2D BarCodes in Java applications


  • Easy to generate barcodes in Java Class, J2EE, Java reporting applications
  • Simple to redistribute Java barcode library. No registration key. No activation code.
  • Generating high quality Bar Code images in GIF, PNG, JPEG & BITMAP
  • Completely developed in Java
  • Compatible with latest barcode symbology ISO Standards
  • Mature barcode generation Java library used by 2000+ clients



Java Barcode Generator is a Java barcode generation library which generates high quality 1D (linear) and 2D (matrix) barcodes.



How to Generate barcodes using Java Barcode?

  • Download the trial version of Java Barcode

  • Add barcode.jar to your Java project classpath

  • Select the right barcode type, and set the barcode properties, like this.
    8     Code39 barcode = new Code39(); 
    9            barcode.setData("0123456789"); 
    10          barcode.drawBarcode("C://barcode.gif"); 
    


  • call barcode.drawBarcode() method to draw barcode on image file or paint barcode in the memory




Java Barcode Generation FAQ?

  1. How to generate barcodes in Java class?

    // Create Java barcode object 
    Code128 barcode = new Code128(); 
    
    // Set barcode data text to encode
    barcode.setData("Create Barcode in Java"); 
    
    // Generate barcode & print into Graphics2D object
    barcode.drawBarcode("Java Graphics2D object"); 
    
    // Generate barcode & encode into GIF format
    barcode.drawBarcode("C://barcode-code128.gif"); 
    
    // Generate barcode & encode into JPEG format
    barcode.drawBarcode("C://barcode-code128.jpg"); 
    
    


  2. How to generate & encode barcodes to EPS?

    // Create Java barcode object 
    Code128 barcode = new Code128(); 
    
    // Set barcode data text to encode
    barcode.setData("Generate Barcode in EPS using Java"); 
    
    // Generate barcode & encode into EPS format
    barcode.drawBarcode2EPS("C://barcode-code128.eps"); 


  3. How to create & encode barcode image in html or jsp pages?



    • Under demo package, copy barcode folder and its contents to your tomcat.

    • Start tomcat, navigate to http://YourDomain:Port/barcode/barcode?DATA=0123456789&TYPE=CODE128

    • To create bar code images in html or jsp pages, you can insert a image tag (img) into your page.
      For example, <img src="http://YourDomain:Port/barcode/barcode?DATA=0123456789&TYPE=CODE128" />



  4. How to create & print barcode image in Java Servlet class?

    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); 
            } 
        } 
    } 


  5. How to generate barcode image in Jasper Reports?


    Complete Guide for Barcode Generation in Jasper Reports

  6. How to generate barcode image in iReport?


    Complete Guide for Barcode Generation in iReport

  7. How to generate barcode image in Eclipse BIRT?


    Complete Guide for Barcode Generation in Eclipse BIRT

  8. How to set generated barcode image width and height?

    1) You can set barcode image width and height through properties barcodeWidth and barcodeHeight values.

    or

    2) You can set X (bar module width) and Y (bar module height) values





Java Barcode Generator Supporting Standards (Click to view each barcode type properties)



Barcode Generation Guide for .NET / Java Developers

.NET Barcode Generation     |     C# Barcode Generation     |     ASP.NET Barcode Generation     |     VB.NET Barcode Generation

Java Barcode Generation