- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
Code 39, also known as Alpha39, Code 3 of 9, Code 3/9, Type 39, USS Code 39, or USD-3, is the first alpha-numeric linear barcode symbology used world-wide.
Generate and create Code 39 barcode using Java is one of the functions in OnBarcode's
Barcode for Java Generating Java library (jar file), which supports
generating & printing Code 39 and 20+ other linear & 2D bar codes in Java application and software.
Code 39 Generator and Reader library, SDK & application
Code 39 Generator components and software include
Code 39 in .NET,
Code 39 in C#,
Code 39 in VB.NET,
Code 39 in ASP.NET,
Code 39 Generator.
This document is providing a detailed Java sample source code about generating Code 39 barcodes in Java class using
Java Barcode generation component.
Complete Code 39 custmoization settings is included in
Java Code 39 generating guide.
Generating Code 39 barcode in Java class example:
Code39 barcode = new Code39(); /* Code 39 Valid data char set: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 (Digits) A - Z (Uppercase letters) - (Dash), $ (Dollar), % (Percentage), (Space), . (Point), / (Slash), + (Plus) Code 39 extension Valid data char set: All ASCII 128 characters */ // Code 39 encodes upper case chars only, for lower case chars, use Code 39 extension barcode.setData("123456789012"); barcode.setExtension(false); barcode.setAddCheckSum(true); // Code 39 Wide Narrow bar Ratio // Valid value is from 2.0 to 3.0 inclusive. barcode.setN(3.0f); // The space between 2 characters in code 39; This a multiple of X; The default is 1.; // Valid value is from 1.0 (inclusive) to 5.3 (exclusive) barcode.setI(1.0f); barcode.setShowStartStopInText(true); // Code 39 Unit of Measure, pixel, cm, or inch barcode.setUom(IBarcode.UOM_PIXEL); // Code 39 barcode bar module width (X) in pixel barcode.setX(1f); // Code 39 barcode bar module height (Y) in pixel barcode.setY(75f); // Code 39 image margins barcode.setLeftMargin(0f); barcode.setRightMargin(0f); barcode.setTopMargin(0f); barcode.setBottomMargin(0f); // barcode image resolution in dpi barcode.setResolution(72); // disply barcode encoding data below the barcode barcode.setShowText(true); // barcode encoding data font style barcode.setTextFont(new Font("Arial", 0, 12)); // space between barcode and barcode encoding data barcode.setTextMargin(6); // barcode displaying angle barcode.setRotate(IBarcode.ROTATE_0); barcode.drawBarcode("C:\\code39.gif");