Java Barcode  >  Java Barcode Generation Guide  >  Java Barcode UPC E Generator for Java Class


Java Barcode UPC E Generator


Barcode UPC-E Generation in Java Class, Jasper Reports, iReport, BIRT

Java Barcode offers the most affordable Java barcode generator for barcode Java professionals.


Java UPC-E Introduction


UPC-E is also known as Universal Product Code version E, UPC-E Supplement 5/Five-digit Add-On, UPC-E Supplement 2/Two-digit Add-On, UPC-E+5, UPC-E+2, UPC-E0, E0, UPC-E1, E1, GTIN-12 with lead "0", GS1-12, UCC-12

UPC-E is a variation of UPC-A which allows for a more compact barcode by eliminating "extra" zeros.
Since the resulting UPC-E barcode is about half the size as an UPC-A barcode, UPC-E is generally used on products with very small packaging where a full UPC-A barcode couldn't reasonably fit.
A UPC-E barcode represents 6 digits with an implied number system 0.


Java Barcode UPC-E Generator - How to generate barcode UPC-E in Java Class?

The following Java code illustrates how to generate a barcode in Java class:

BarCode barcode = new BarCode(); 

// set barcode properties
barcode.setSymbologyType(BarCode.UPCE_2); 
barcode.setCodeText("666666"); 
barcode.setSupplementData("22"); 
  
// draw and generate barcode to buffered image object
BufferedImage upceImage = barcode.drawBarCode2Image();


Java Barcode UPC-E Generator - How to generate UPC-E barcodes to Java Servlet applicatons?

The following Java code illustrates how to generate a barcode in Java Servlet class:

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.UPCE); 
            barcode.setCodeText("666666");
            
            // draw and generate barcode to response's ServletOutputStream 
            ServletOutputStream servletoutputstream = response.getOutputStream(); 
            
            barcode.drawBarCode2Stream(servletoutputstream); 

        } catch (Exception e) { 
            throw new ServletException(e); 
        } 
    } 
}


Java Barcode UPC-E Generator - How to create UPC-E barcodes through HTTP Request?

  1. Install Java Barcode Generator Servlet application to Tomcat or JBoss, developers need copy the barcode folder to your Tomcat application folder, and restart the Tomcat.

  2. After Tomcat restarted, open your browser and navigate to http://your_tomcat_url:port/barcode/barCode?code-text=666666&symbology-type=22

  3. You can also insert barcodes in HTML or JSP pages.

    <img src="http://your_tomcat_url:port/barcode/barCode?code-text=666666&symbology-type=22">


Java Barcode UPC-E Generator - How to draw & print barcode UPC-E to java.awt.Image Object

The following Java source code shows how to generate a barcode in a java.awt.Image object:

private static void demoLinearBarcode() throws Exception 

    BarCode barcode = new BarCode(); 

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

    // 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 UPC-E Properties


UPC-E Type Value: com.keepdynamic.barcode.generator.BarCode.UPCE (22).

UPC-E Supplement 2 Type Value: com.keepdynamic.barcode.generator.BarCode.UPCE_2 (23).

UPC-E Supplement 5 Type Value: com.keepdynamic.barcode.generator.BarCode.UPCE_5 (24).