Barcode Generation in Java Class
How to create linear, 2D barcode images in Java Class Library Application
Download Java Barcode Generator Free Evaluation
Purchase Java Barcode Generator SDK License
We found the Java Barcode an easy barcode solution for JasperReports.
- Gary Lipkowitz, USA

Creating, printing high-quality barcode images using Java sample code

  • Mature Java Barcode library tool with Headless Java support
  • Supporting JDK 1.4.2 and later versions
  • More than 30 barcode types (QR Code included) combined into single jar file
  • Java sample code provided to create valide barcode images in Java Class
  • Add barcode functionality into Jasper Report, iReport, Oracle Report & Eclipse BIRT with Java core
  • Easy interface to print barcode using Java code programming and adjust size, resolution, rotation, etc
  • Simple to generate best Java bar code labels in Jpeg, Gif, Png image formats
  • Check character automatically calculated for those linear barcodes required
  • Professional Java barcode SDK with outstanding barcode output
This page is a tutorial to create postal and other linear, two-dimensional barcodes in Java Class using advanced OnBarcode Java Barcode Generator Library. Java sample codes are provided as how to generate barcodes, adjust barcode size, and customize barcode image formats using Java coding. Developers can store barcode image to database for later use. For Java server-side or client-side applications, please navigate to corresponding guide page.
OnBarcode also provides other Java barcode example tutorials:
  1. Java Barcode Generator Tutorial - How to generate & draw multiple barcode images in Java applications
  2. Java Servlet Barcoder Tutorial - How to stream & display barcodes in Java web applications (JSP Servlet / html pages)
  3. iReport Barcode Tutorial - How to print & embed barcode pictures in iReport with Java Barcode Plugin
How to Install Java Barcode Library
  1. Open your IntelliJ IDEA and create a new project
  2. Add a Directory named "lib" in the Java project built step ahead
  3. Download the free java barcode trial, unzip the package and copy the barcode.jar file into the lib file
  4. In Modules settings, add the barcode.jar file to classpath
  5. Create a new class and copy the following Java sample code to your program for barcode generation & implementation
How to Create Barcodes in Java Class Library
This Java Barcode Generator supports printing over 30 barcode types. In the following part, we will take Code 39 as example to show Java barcode generation, image format setting, resolution, rotation and other output methods. You can view Java barcode generator api in the below demo. For embedding java barcode with number digit or alphanumeric string value, try other barcode symbols.
OnBarcode also provides specific guide to encode barcode data, or customize barcode image:
  1. Java Barcode Data Encoding Tutorial - How to create GS1-Compatible Barcodes or encode Unicode into Java Barcodes
  2. Java Barcode Image Setting Tutorial - How to generate barcodes in Java and adjust barcode image properties

Example to Adjust Barcode Dimension in Java Class

import com.onbarcode.barcode.Code39;

public class tutorial {
public static void main(String[] args)
Code39 barcode = new Code39();


catch(Exception e)

Print Barcodes in Java Class in Png, Gif, Gif or EPS Image Formats

Code39 barcode = new Code39();

//Generate barcode in Gif image format

//Generate barcode in JPEG image format

//Generate barcode in PNG image format

//Generate barcode in EPS image format. The filename must ends with .eps

More Barcode Settings in Java Class

//Set barcode image bar alignment property

//Customize barcode image resolution

//Set barcode rotation rate. 0 degree(0), 90 degree(1), 180 degree(2), 270 degree(3)

//Customize barcode human-readable text
barcode.setTextFont(new Font("Arial", Font.BOLD, 11));

//Adjust barcode image color


More Barcode Generation Output Methods

// generate barcode and output to OutputStream object
public boolean drawBarcode(OutputStream outputStream) throws Exception

// generate barcode into a new BufferedImage object
public BufferedImage drawBarcode() throws Exception

public byte[] drawBarcodeToBytes() throws Exception

public boolean drawBarcode(String imageFile) throws Exception

// Generate barcode on Graphics2D object within certain area
public void drawBarcode(Graphics2D g, Rectangle2D rectangle) throws Exception
Java Barcode Generation Guide for Linear & 2D Barcode Types

Java Barcode Library SDK - Barcodes Generation

OnBarcode is a market-leading provider of barcode imaging generator, reader controls and components for ASP.NET, Windows Forms, WPF, as well Java, Android, iOS (iPhone, iPad) across all major enterprise development platforms. We provides comprehensive tutorials and how-tos for various linear, 2d barcode information, such as C# in ASP.NET, C# .NET, C# Barcode Encoding, C# Barcode Image, VB.NET in ASP.NET, VB.NET Winforms, VB.NET Barcode Encoding. OnBarcode barcode products are supported by RasterEdge ASP.NET Document Viewer, which supports ASP.NET PDF Viewer, ASP.NET MVC Document Viewer, ASP.NET PDF Editor, MVC PDF Viewer. And provide high quality C# Convert PDF to Tiff, C# Convert PDF to Word, C# Convert PDF to HTML, C# Convert PDF to Jpeg images, and their easy and simple documents, like C# PDF SDK, C# extract text from PDF, C# Compress PDF, Print PDF in C# and C# extract image from PDF.
Terms of Use | Privacy Policy
Copyright © . All rights reserved.