Java Barcode  >  Java Barcode Generation Guide  >  Java Barcode EAN 8 Generator for Java Class

Java EAN-8 Generator

Barcode EAN-8 Generation in Java Class, Jasper Reports, iReport, BIRT

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

Java EAN-8 Introduction

EAN-8 is also known as European Article Number 8, EAN-8 Supplement 5/Five-digit Add-On, EAN-8 Supplement 2/Two-digit Add-On, EAN-8+5, EAN-8+2, EAN8, EAN8+5, EAN13+2, UPC-8, GTIN-8, GS1-8, EAN/UCC-8

An EAN-8 is a barcode and is derived from the longer European Article Number (EAN-13) code. It was introduced mainly to use on small packages where an EAN-13 barcode would be impractical; for example on cigarettes, pencils even though not used very common and chewing gum packets.

Java Barcode EAN-8 Generator - How to generate barcode EAN-8 in Java Class?

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

BarCode barcode = new BarCode(); 

// set barcode properties
// draw and generate barcode to buffered image object
BufferedImage ean8Image = barcode.drawBarCode2Image();

Java Barcode EAN-8 Generator - How to generate EAN-8 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 
            // draw and generate barcode to response's ServletOutputStream 
            ServletOutputStream servletoutputstream = response.getOutputStream(); 

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

Java Barcode EAN-8 Generator - How to create EAN-8 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=7777777&symbology-type=13

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

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

Java Barcode EAN-8 Generator - How to draw & print barcode EAN-8 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 

    // 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 EAN-8 Properties

EAN-8 Type Value: com.keepdynamic.barcode.generator.BarCode.EAN8 (13).

EAN-8 Supplement 2 Type Value: com.keepdynamic.barcode.generator.BarCode.EAN8_2 (14).

EAN-8 Supplement 5 Type Value: com.keepdynamic.barcode.generator.BarCode.EAN8_5 (15).