Barbecue is a free and open source Java library for Barcode generation. This requires the library barbecue-1.5-beta1.jar to be in classpath. The following example shows how to save CODE 128B Barcode as GIF image.
package com.bethecoder.tutorials.barbecue; import java.io.File; import net.sourceforge.barbecue.Barcode; import net.sourceforge.barbecue.BarcodeFactory; import net.sourceforge.barbecue.BarcodeImageHandler; public class BarCodeGifTest { public static void main (String [] args) throws Exception { //Get 128B Barcode instance from the Factory Barcode barcode = BarcodeFactory.createCode128B("be the coder"); File imgFile = new File("test128b.gif"); //Write the bar code to GIF file BarcodeImageHandler.saveGIF(barcode, imgFile); } }