.NET Barcode for WinForms          ASP.NET Barcode          .NET Barcode Reader          Java Barcode          Java Barcode Reader
Home > Java Barcode > Java Code 39 Generator

Java Code 39 Generator

Java Code 39 Generation package to generate Code 39 linear barcodes in Java applications

  • Mature Java Code 39 package consists of class library contains all necessary class files for java Code 39 barcode generation.

  • Generate, create Code 39 in Java class, Java bean, Servlet, EJB.

  • Java Code 39 can be easily generated on any operating system with a JVM.

  • Generate Code 39barcodes in Jasper Reports, iReport & Eclipse BIRT

  • Java Code 39 generator is compatible with JDK 1.4.0 or greater.

Java Code 39 Generator - Overview

Java Code 39 generator is a mature and reliable Java barcode generation component for creating Code 39 barcodes in Java, Jasper Reports, iReport, and Eclipse BIRT projects. High-quality Code 39 barcode images can be drawn and printed into GIF, BMP, PNG, JPEG/JPG & TIFF formats with Java Code 39 barcode generator. Rich barcode options are provided to customize Code 39 barcode properties in accordance with your needs.

Code 39 information:

Code 39: also called "Code 3/9", "code 3 of 9", "USS Code 39", "Alpha 39" and "USD-3", is an alpha-numeric barcode symbology, which is discrete and widely-used.

Available encoding digits:

Uppercase letters (A - Z)
Special digits: - $ % Space . ,/+


The structure of a Code 39:

1. A start character - the asterisk (*) character.
2. Encoded characters.
3. An optional checksum digit .
4. A stop character, a second asterisk character.

Java Code 39 Generator Implementation to Generate Code 39

1. Generate Code 39 in Java class by changing of barcode properties.

// Create Java barcode object

Code39barcode = new Code39();

// Set barcode data text to encode


// Generate barcode & print into Graphics2D object

barcode.drawBarcode("Java Graphics2D object";);

// Generate barcode & encode into GIF format

barcode.drawBarcode("C://barcode- code 39.gif";);

2. Generate & encode Code 39 to EPS by changing the values concerned.

// Create Java Code39 object

Code39 barcode = new Code39();

// Set Code39 data text to encode

barcode.setData("CREATE CODE39 IN EPS";);

// Draw Code39 barcode & paint into EPS image format


3. Generate & encode Code 39 in html or 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=1234567&TYPE=CODE39

3.To create bar code images in html or jsp pages, you can insert a image tag (img) into your page.

For example, <img src="http://YourDomain:Port/barcode/barcode?DATA=1234567&TYPE=CODE39" />

4. 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.

4. Two ways to set the width and height of generated barcode Code 39 image.

1. Set the values of the barcodeWidth and barcodeHeight properties.
2. Set X (bar module width) and Y (bar module height) values

Code 39 Property Settings in Winforms Barcode Generator

Code 39 Basic Settings

Properties Value Comments
Property URL Options Default
data DATA (Data to encode in the Codabar) "" Code 128 value to encode

Code 128 Character Set:

all 128 ASCII characters (Char from 0 to 127)
addCheckSum ADD-CHECK-SUM (Data to encode in the Codabar) false addCheckSum property is not applied here.

Code 39 Special Settings

Properties Value Comments
Property URL Options Default

For encoding lower case letters and other 128 ASCII characters,please set extension property to true.

process Tilde

Set the processTilde property to true, if you want use the tilde character "~" to specify special characters in the input data, such as non-printable chars in ASCII table.

1-byte character: ~0dd/~1dd/~2dd (character value from 000 ~ 255); Strings from "~256" to "~299" are unused
L foloat
The space between 2 characters in code 39. This a multiple of X module (bar width).

a * will appear in the beginning and the end of barcode text in Code 39 if ture.

N float
Wide bar vs narrow bar ratio. Valid values are 2.0 - 3.0 inclusive, default is 2.0..

Code 39 Text Settings

Properties Value Comments
Property URL Options Default
SHOW-TEXT true or false true
Show text underneath the barcode

Color of the shown text
New font("Arial",Font.PLAIN,11)

The font, font style and font size of the text.

In Java Servlet web streaming, using the url paramter in the following format:

The space between the text and the barcode symbol

Code 39 Size Settings

Properties Value Comments
Property URL Options Default

Rotate Degree0, 90, 180, 270

Rotate the Angle of the Codabar images with:

0 (IBarcode.ROTATE_0)
1 (IBarcode.ROTATE_90)
2 (IBarcode.ROTATE_180)
3 (IBarcode.ROTATE_270)
AUTO-RESIZE true or false
Auto resize the generated barcode image

barcodeHeight BARCODE-HEIGHT float
Barcode image Height
barcodeWidth BARCODE-WIDTH float
Barcode image Width
Barcode image bottom margin size
leftMargin LEFT-MARGINE float 0

Barcode image left margin size

rightMargin RIGHT-MARGIN float 0
Barcode image right margin size.

topMargin TOP-MARGIN float 0

Barcode image Top margin size
barAlignment BARALIGMENT int 1(center)

Barcode horizontal alignment inside the image. 0: left, 1: center, 2: right.
uom UOM Pixel, Cm, or Inch 0(Pixel)
Unit of Measure for all numeric properties.Valid values: 0: pixel; 1: inch; 2: cm.
X X float 1
Width of barcode bar module (narrow bar), default is 1 pixel

Y Y float 30
Height of barcode bar module, default is 30 pixel

Code 39 Color Settings

Properties Value Comments
Property URL Options Default
BACK -COLOR Color white Barcode image background color
black Barcode image foreground color

Code 39 Image Settings

Properties Value Comments
Property URL Options Default
RESOLUTION int 72 Resolution of Codabar Image, Dots Per Inch


// 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

Use this method to generate barcode, and save into gif or jpeg files
1. to save into gif file, filename ends with ".gif", like "c:\\barcode.gif"
2. to save into jpeg file, filename ends with ".jpg", like "c:\\barcode.jpg"

public byte[] drawBarcodeToBytes() throws Exception

public boolean drawBarcode(String imageFile) throws Exception

// Generate barcode and save into EPS file, the filename must ends with ".eps"
public void drawBarcode2EPS(String filename) throws Exception

// Generate barcode on Graphics2D object within certain area
public void drawBarcode(Graphics2D g, Rectangle2D rectangle) throws Exception