Home > Barcode for Java > Java Barcode Generation Guide - How to use Java Barcode Generator Library to generate linear & 2d barcode images
Java Barcode Generation Guide
How to Generate and Draw 1D & 2D Barcode Images for Java Applications
Generating linear & 2D barcode images using Barcode for Java library, is a simply and easy task.
This page is a demonstration and tutorial on how to generate barcode images using Java Barcode Generator library in your Java programs. Please download free Java Barcode Library trial first to get started.
Barcode for Java Trial Package Overview
Barcode for Java is a mature & reliable Java barcode generator library for linear & 2d barcode generation in J2SE, J2EE, and Java reporting framework applications (Jasper Reports, iReport and Eclipse BIRT).
Barcode for Java trial package includes:
barcode.jar, Java classes includes all supporting barcode types and functions
/demo-src, Contains demo Java souce code for barcode generation
/javadoc, Java docs
/Developer-Guide.html, Guide for developers to use this Java bar coding library
/barcode, Contains Barcode for Java Buildin Barcode Generation web application for developers. See how to
LicenseAgreement.txt, Barcode for Java End-User License Agreement
Install Barcode for Java Library
Install Barcode for Java Library to your Java Projects
Copy barcode.jar file to your Java project library folder, and add barcode.jar to your project reference
Install Barcode for Java Library to your Java web applications
Set QR-Code object barcode image properties (line 2)
Generate QR-Code barcode and encode into gif image format (line 3)
Generate QR-Code and output to BufferedImage object (line 4)
Generate QR-Code in bitmap and output to byte[] (line 5)
Generate QR-Code and draw to defined area (Rectangle2D) on Graphics2D (line 6-8)
Generate QR-Code and output to OutputStream (line 9-10)
How to Generate Barcode Image in Web Applications?
There are two ways to create barcode images in your Java web applications.
The simplest way - How to generate barcode image is to use our Build-in Barcode Generation web application (The application is included in Barcode for Java trial package. download it). And it will not save generated barcode images in your server side. Follow the steps to see how:
Copy folder barcode, under BarcodeLib_JavaBarcode_Trial (or BarcodeLib_JavaBarcode_Production), to your java servlet container like Tomcat.
Restart Tomcat, and test your installation, open web browser and navigate to: http://YourDomain:Port/barcode/linear?Data=123456789&Type=CODE128
To create & insert barcode images in your JSP or html pages, you can pass the url to IMG tag src value. For example, <img src="http://YourDomain:Port/barcode/linear?Data=123456789&Type=CODE128" />
The second method - Similar with the way to generate barcode in Java class.
Create a barcode & save the barcode image to your server side: Linear linear = new Linear(); linear.setData("123456789"); linear.setType(Linear.CODE128); linear.renderBarcode("C:/Tools/Tomcat 5.5/webapps/YourWebApp/bimages/barcode.gif");
In your JSP page, you can using IMG tag to display generated image, like: <img src="http://YourDomain:Port/YourWebApp/bimages/barcode.gif" />
How to Generate Barcode Images in JasperReports, iReport & Eclipse BIRT Programs?