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 set Barcode width and height.
public static void main (String [] args) throws Exception {
//Get 128B Barcode instance from the Factory
Barcode barcode = BarcodeFactory.createCode128B("be the coder");
barcode.setBarHeight(60);
barcode.setBarWidth(2);
File imgFile = new File("testsize.png");
//Write the bar code to PNG file
BarcodeImageHandler.savePNG(barcode, imgFile);
}
}