Java Code 39 Generator Tutorial

Generate, create barcode Code 39 images in Java Class, JSP Pages, Jasper Report, Eclipse BIRT

Generate, Create, Print, Draw Code 39 barcode in Java projects

  • Easy to Generate Code 39 in Java class, Java Bean, Applet, Swing applications
  • Create Code 39 in JSP, Java Servlet, EJB, Tomcat, JBoss server side projects
  • Print, draw Code 39 barcode images in Jasper Reports, iReport & Eclipse BIRT Java reporting software
  • Generating & encoding high quality Code-39 Bar Code images in GIF, JPEG, & EPS formats formats
  • Compatible with ISO / IEC 16388 (2nd edition 2007-05-15)
  • Completely written in Java source code
  • Simple to redistribute Java Code 39 barcode library. No registration key. No activation code
  • Mature Code-39 barcode generation Java library


How to create, print Code 39 barcode in Java web, desktop application?

  1. Download Java Code 39 Barcode Generator library
  2. Install Java Code 39 barcode generation library into Java project
  3. Start to Create










Java Barcode Code 39 Generator Introduction

Top
Java Barcode Code 39 is a Java barcode generator library which generates industry standard Code 39 and other 1D (linear) and 2D (matrix) barcode images in Java, Jasper Reports, iReport, and Eclipse BIRT projects.

You can download the trial package of Java Barcode library, which includes compiled Java library (Jar file) to generate Code 39 in your Java program, detailed tutorial for generating barcodes in Java, and complete sample Java source code to generate Code 39 in Java class. Downloaded Java barcode generation software allows you to create and print QR Code, Data Matrix, PDF417, Code 128, Code 93, Intelligent Mail, UPC, OneCode and other linear and 2d barcodes.

Barcode Code 39 Introduction

Code 39 (also known as "USS Code 39", "Code 3/9", "Code 3 of 9", "USD-3", "Alpha39", "Type 39") is a barcode symbology that can encode uppercase letters (A through Z), digits (0 through 9) and a handful of special characters like the $ sign. Code 39 is restricted to 44 characters.




How to Generate Code 39 in Java Class?

Top
Using Java Barcode Generator library, you can quickly create a Code 39 barcode in Java class.
  • Create a new Code39 object
  • Set the Code 39 encoding data
  • Call drawBarcode() method to print Code 39 to a PNG image file
  • You can also use drawBarcode() method to create Code 39 barcode in memory
Code39 barcode = new Code39();
barcode.setData("CODE-39");		
barcode.drawBarcode("c://Output//OnBarcode.com//java-code39-demo.png");





Code 39 extension mode

To encode lower case letters in Code 39, you need enable Code 39 extension data mode.

Call method setExtension(true) to apply the Code 39 extension mode.

Code39 barcode = new Code39();
barcode.setExtension(true);
barcode.setData("Code-39");		
barcode.drawBarcode("c://Output//OnBarcode.com//java-code39-extension-demo.png");





Code 39 Encoding Characters in Java

Top

Java Code 39 Generator encodes:
  • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
  • Uppercase letters (A - Z)
  • - (Dash), $ (Dollar), % (Percentage), (Space), . (Point), / (Slash), + (Plus)
  • Code 39 Extension can encodes all 128 ASCII characters




How to print and customize Code 39 barcode in Java

Top

Add checksum digit to Code 39

By default, the Code 39 does not contain check sum digit. You can apply it by calling method setAddCheckSum(true) in Java barcode library.

Code39 barcode = new Code39();
barcode.setData("CODE-39");
barcode.setAddCheckSum(true);
barcode.drawBarcode("c://Output//OnBarcode.com//java-code39-add-checksum.png");





Hide Code 39 checksum in text label

When the check digit is applied in the Code 39 barcode, you can choose to hide the check digit label from Code 39 barcode text label.

Disable check sum digit in text label using method setShowCheckSumChar(false) in Java class.

Code39 barcode = new Code39();
barcode.setData("CODE-39");
barcode.setAddCheckSum(true);
barcode.setShowCheckSumChar(false);
barcode.drawBarcode("c://Output//OnBarcode.com//java-code39-hide-checksum.png");





Hide Code39 start, stop chars

Code 39 barcode includes a Start character (*) and a Stop character (*). You can hide them from the Code 39 text label using Java Barcode Generator library.

Call method setShowStartStopInText(false) to hide the start/stop chars from Code 39 barcode human readable text label.

Code39 barcode = new Code39();
barcode.setData("CODE-39");
barcode.setShowStartStopInText(false);
barcode.drawBarcode("c://Output//OnBarcode.com//java-code39-hide-start-stop-chars.png");



Code 39 Wide bar size vs Narrow bar size ratio (N)

Using Java Code 39 Barcode Generator library, you can change the Code 39 wide bar vs narrow bar ratio through property N. The valid Code 39 wide vs narrow bar ratio is 2.0 to 3.0 (inclusive).

The barcode property N valid value is from 2 to 3 (both inclusive). The default is 2.

barcode.N = 3;



Code 39 Intercharacter space (I)

You can specifiy the space size between each two Code 39 characters bars through property I in Java class.

The property I is the space between 2 character bar modules, and it is a multiple of X (narrow bar module width). The default value is 1.0.

barcode.I = 2;





How to Create Code 39 image in JSP and Servlet Java web applications?

Top

Code 39 in JSP pages

  1. Under demo package, copy barcode folder and its contents to your tomcat.
  2. Start tomcat, navigate to http://YourDomain:Port/barcode/barcode?DATA=0123456789&TYPE=CODE39
  3. To create bar code images in html or jsp pages, you can insert an image tag (img) into your page.
  4. For example, <img src="http://YourDomain:Port/barcode/barcode?DATA=0123456789&TYPE=CODE39"/>
  5. The above Java codes will not produce any Code 39 image files in your server system, using the above methods to draw Code 39 in JSP, html pages.




Code 39 in Java Servlet

OnBarcode Java Barcode Generator library supports Code 39 barcode generation in both Jakarta Servlet and Javax Servlet.
import com.onbarcode.barcode.AbstractBarcode; 
import com.onbarcode.barcode.Code39;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;

public class BarcodeServlet extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException
{
try {
Code39 barcode = new Code39();
barcode.setData("0123456789");

ServletOutputStream servletoutputstream = response.getOutputStream();

response.setContentType("image/jpeg");
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);

// Generate Code-39 barcode & output to ServletOutputStream
barcode.drawBarcode(servletoutputstream);

} catch (Exception e) {
throw new ServletException(e);
}
}
}




How to Generate & Print Barcode Code 39 barcodes in Java report applications?

Top
Using OnBarcode Java Barcode Generator library, you can generate and insert Code 39 barcodes in Java reports in Java reporting applications. We recommend you use our BIRT Barcode Generator to generate and print Code 39 barcodes in your BIRT reports.

How to Set Generated Barcode Code 39 Image Width and Height?

Top
  1. You can set barcode image width and height through properties barcodeWidth and barcodeHeight values.
  2. Or you can set X (bar module width) and Y (bar module height) values




Java Code 39 Generator - Property Settings

Top
Java Code 39 Generator - in Java Class: com.onbarcode.barcode.Code39

View the details here: complete Code 39 barcode property settings in Java class













Common Asked Questions

What is Code 39 barcode used for?

Code 39, also known as Code 3 of 9, is the first barcode symbology to encode both numbers and letters (Upper case letters only). It is most commonly used in the inventory, government, military and electronics industries.

Using Java barcode generator library, you can need create and initiate a new com.onbarcode.barcode.Code39 object to create Code 39 or Code 39 extension barcodes. Standard or regular Code 39 barcode encodes upper-case letters only. To encode lower-case letters, you need choose Code 39 extend barcode.

To create Code 39 extended barcodes using Java, set the methodCode39.setExtension(true).

Can Code 39 barcode encode lowercase letters in Java class?

Code 39 barcode standard version does not support lowercase letters encoding. However the Code 39 extended version does. OnBarcode Java Barcode Generator library does support both Code 39 standard and extend versions. In Java class Code39, by default it will create standard Code 39 barcode images. To create Code 39 extended barcodes using Java, set the methodCode39.setExtension(true) in Java JSP, Servlet web and J2EE application.

What is the minimum size for Code 39 barcode?

Code 39 barcodes need meet the following barcode dimension size requirements.
  • Code39.setX() (X): the mimumum bar width (X module) is defined by the application specification. In Java class, you can create and customize the Code 39 bar/space module width through method Code39.setX()
  • Code39.setBarcodeHeight(): the minimum height is 5.0mm or 15% of symbol width (excluding quiet zones), whichever is greater. Using Java barcode library, you can generate and customize the Code 39 barcode image height through method Code39.setBarcodeHeight() in Java class com.onbarcode.barcode.Code39

What is the ratio of narrow to wide bars in Code 39 barcode?

The valid ratio of Code 39 narrow to wide bars is from 1:2 to 1:3 inclusive. You can apply the Code 39 bars ratio configure through method Code39.setN() using Java barcode generation library.

What is the difference between barcode 39 and barcode 93?

Bath Code 39 and Code 93 are linear (1d) barcode formats. Code 93 is an updated version of Code 39. Code 93 is a higher-density barcode type compared to Code 39. Java barcode library supports both Code 39 and Code 93 barcodes generation and printing in Java Tomcat web and J2EE applications.

In Java class Code39, by default it will create standard Code 39 barcode images. To create Code 39 extended barcodes using Java, set the methodCode39.setExtension(true) in Java JSP, Servlet web and J2EE application.

Creating a new Code93 to encode and print Code 93 barcode images in Java project.

What is the difference between Code 39 and Code 128 barcodes?

Bath Code 39 and Code 128 are linear (1d) barcode symbologies. Code 128 requires a compulsory checksum digit. If the Code 128 barcode is damaged, it may still be scannable. Code 39 checksum is optional. If the Code 39 barcode without checksum is damaged, it won't be scannable. In Java class, you can generate Code 39 barcode with or without check sum applied using Java Barcode Generator library.

In Java, set method Code39.setAddCheckSum() with true value to append a checksum character to the end of Code 39 barcode.




































Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.