Java Barcode Generator, .NET Barcode Generator for C#, ASP.NET, VB.NET
HOME BARCODE FOR JAVA PURCHASE

Barcode for Java Developer Guide



Quick Navigate
 

1. Trial Package Overview

Barcode for Java trial package includes:

  • barcode.jar, Java library includes all supporting barcode types and functions for barcode generation in Java class, Java web application, Jasper Reports, iReport, & Eclipse BIRT.
  • DeveloperGuide.html, guide for developers to use this library
  • /barcode, contains Barcode for Java Buildin Barcode Generation web application for developers.
  • /javadoc, contains Barcode for Java API.
  • /demo-src, complete source code for the demo application.
  • LicenseAgreement.txt, Barcode for Java End-User License Agreement

 

2. Install

Install barcode library to your Java project

  • Add barcode.jar to your Java project classpath or your project library
 

Install Barcode Servlet Web Application

  • Copy barcode folder in downloaded trial pacakge to your java servlet container like tomcat.
  • Restart Tomcat
  • To test your installation, open your web browser, and navigate to
    http://localhost:8080/barcode/linear?Data=123456789&Type=CODE39
    You will see a Code39 image displayed in the browser.
  • To create barcode image in your JSP or html page, you can pass the url to IMG tag src value. For example,
    <img src="http://localhost:8080/barcode/linear?Data=123456789&Type=CODE39" />

 

3. Generating Barcodes in Java Class

The following code illustrates how to create a barcode in a Java class

  • Linear barcode = new Linear();
  • barcode.setType(Linear.CODE39);
  • // barcode data to encode
  • barcode.setData("CODE39-123456789012");
  •  
  • // wide bar width vs narrow bar width ratio
  • barcode.setN(3.0f);
  •  
  • barcode.renderBarcode("c://code39.gif");
  •  

    4. Generating Barcodes in Java Web Application

    There are two ways to create barcode images in your Java web applications.

    1. This is the simplest way to stream barcode image using our provided barcode web application, under folder "barcode".

      And it will not save barcode images in your server side.

      • Install barcode Servlet web application to your Servlet container, such as Tomcat, Jboss.
      • To create barcode images in your JSP or html pages, you can pass the url to IMG tag src value.

        For Linear barcode: <img src="http://localhost:8080/barcode/linear?Data=123456789&Type=CODE39" />

        For Data Matrix: <img src="http://localhost:8080/barcode/datamatrix?Data=123456789" />

        For PDF417: <img src="http://localhost:8080/barcode/pdf417?Data=123456789" />

        For QR Code: <img src="http://localhost:8080/barcode/qrcode?Data=123456789" />

    2. The second method is similar with the way to generate barcode in Java applications.

      • To create barcodes in your Java server side class, view the above example.
      • To output barcode image to Java Servlet HttpServletResponse object:
    1. public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException
    2. {
    3.     try {
    4.         Linear barcode = new Linear();
    5.         barcode.setType(Linear.CODE39);
    6.         barcode.setData("CODE39-123456789012");
    7.        
    8.         response.setContentType("image/gif");
    9.         ServletOutputStream servletoutputstream = response.getOutputStream();
    10.  
    11.         linear.renderBarcode(servletoutputstream);
    12.  
    13.     } catch (Exception e) {
    14.         throw new ServletException(e);
    15.     }
    16. }
     

    5. Generating Barcodes in Java Reporting





    6. Property Settings for Each Barcode Types


     










       Copyright BarcodeLib.com. All rights reserved.