Rechercher dans ce site

Barcode generating in Java, Barbecue, Hello World

>> 21 September 2010

If you are looking for an open source library for generating barcodes from your Java application, then this article is for you.

What is Barbecue :
"Barbecue Project" site's says
"Barbecue is a Java library that enables the creation of barcodes in a variety of standard formats that can be displayed as Swing/AWT components, included in printed output, generated as EPS and SVG and displayed in a web application."

Before going any further, please note that Barbecue will not play on GAEJ, some dependencies are not on the "The JRE Class White List" of Google, for instance JComponent.

Project's Site :

  • Download the current version (In this moment it's 1.5Beta 1)
  • Unzip
  • In a Web App
    • copy barbecue-1.5-beta1.jar to war/WEB-INF/lib
    • copy jdom.jar (in the created folder/lib when unzipping ) to war/WEB-INF/lib
    • Add these two .jar files to YourProject/properties/Java Build Path
  • In a normal Java project
    • Create a folder (give it any name), for instance "lib"
    • copy barbecue-1.5-beta1.jar to YourProject/lib
    • copy jdom.jar (in the created folder/lib when unzipping ) to     YourProject/lib
    • Add these two .jar files to YourProject/properties/Java Build Path

Hello World

import net.sourceforge.barbecue.Barcode;
import net.sourceforge.barbecue.BarcodeException;
import net.sourceforge.barbecue.BarcodeFactory;
import net.sourceforge.barbecue.BarcodeImageHandler;
import net.sourceforge.barbecue.output.OutputException;

 * @author Kaesar ALNIJRES

public class BarCode {

     * @param args
    public static void main(String[] args) {
        //1 get a File reference to save the bar code image
        File file=new File("/home/kas/barcode");
        try {
            //2 create the bar code using a String (your data)
            Barcode barCode=BarcodeFactory.createCode128("Hello World !!!");
        //3 save the generated bar code to the above file as jpeg image
        } catch (OutputException e) {
            // TODO Auto-generated catch block
        } catch (BarcodeException e) {
            // TODO Auto-generated catch block




Dinesh May 2, 2011 at 7:01 PM  

Thank you friend ... You and your team done a great job...

The project was useful for my my friends college "Library Management" project for free as like you.

so keep this good job tick up. At last "Thanks for the project" :)

okjavafx May 3, 2011 at 10:12 AM  

Thank you very much for the comment. You are really very kind.

I'm really pleased that the article was helpful.

Hope to hear from you soon.

Thanks again


John Ortiz Ordoñez January 12, 2012 at 11:17 PM  

Do you know how to use this library in iReport? Thanks in advance.

Post a Comment

  © Blogger template Simple n' Sweet by 2009

Back to TOP