How to Generate 2D Barcode / QR Code in Oracle Reports (Doc ID 1678110.1)

How to Generate 2D Barcode / QR Code in Oracle Reports (Doc ID 1678110.1)


Oracle Reports Developer – Version and later
Information in this document applies to any platform.


Generate an Oracle Report output with 2D Barcode / QR Code image.


NOTE: The sample program in this article is provided for educational purposes only and is NOT supported by Oracle Support Services. It has been tested internally and works as documented. Oracle can not guarantee that it will work in all possible configurations, so be sure to test it thoroughly in your test environment before deploying it.


Since 10gr2 , it is possible to import Java classes in Oracle Reports.

Reports Builder Online Help :
The Java Importer enables you to access the rich environment of the Java programming language from your reports.
 Using the Java Importer, you can automatically generate PL/SQL packages and procedures to access Java classes and then program with the generated PL/SQL in your reports.

Open Source Java Libraries exist to generate 2D Barcode / QR Code / Data Matrix  : XZing , QRGen , Barcode4J , …

The example below is based on the Open Source Java libraries : XZing and QRgen :


To download the Jar files core-1.7.jar , javase-1.7.jar, and qrgen-1.2.jar used in this example please follow the following steps:

[1] core-1.7.jar and javase-1.7.jar files can be downloaded at :

ZXing under the following section:
Just Need a JAR?  
    If you just need a pre-built JAR file, you can always find compiled resources from the Maven release repository, including recent snapshot/nightly builds.

[2] qrgen-1.2.jar can be downloaded at :

QRGen under the following section:
Get it:
    QRGen consists of three modules: core, javase and android. Everything is available from Maven Central Repository.

Note :
1. The example below is written using the Windows platform syntax. The same example can be implemented on “UNIX” platforms.
2. The Jar file names may be different according to the versions of ZXing and QRGen used.
3. The java classes in some jar files of the latest versions of ZXing / QRGen have been generated by the java Compiler 7.
The JDK provided by default in ORACLE_HOME\jdk is the JDK 6.
Classes compiled with the Java compiler 7 cannot be used with the JDK 6The jar files used in this example (core-1.7.jar , javase-1.7.jar , qrgen-1.2.jar) have been used with the default JDK provided in ORACLE_HOME\jdk for FMW 11gR1 and 11gR2


The following are the steps to build a report to generate 2D barcodes

Step 1 . Create the Java code file

import java.util.Arrays;
import net.glxn.qrgen.QRCode;
import net.glxn.qrgen.image.ImageType;public class qrcode {
public static void main(String[] args) {
/* This is an example */
try {
generate (“” , “c:\\temp\\qrcode_temp.gif”);
catch (Exception e) {
public static void generate(String qrcodetext , String imagefilename)
throws Exception
ByteArrayOutputStream out = QRCode.from(qrcodetext).to(ImageType.GIF).stream();
FileOutputStream fout = new FileOutputStream(new File(imagefilename));

Step 2 . Copy the jar files core-1.7.jar , javase-1.7.jar, and  qrgen-1.2.jar in the directory %ORACLE_HOME%\reports\jlib

Step 3 . Compile this java class using the java compiler in %ORACLE_HOME%\jdk\bin

set CLASSPATH=%ORACLE_HOME%\reports\jlib\core-1.7.jar;%ORACLE_HOME%\reports\jlib\javase-1.7.jar;%ORACLE_HOME%\reports\jlib\qrgen-1.2.jar

Step 4 . Copy the file qrcode.class generated in Step 3. in %ORACLE_HOME%\reports\jlib directory


Step 5 . Make sure REPORTS_CLASSPATH environment variable includes %ORACLE_HOME%\reports\jlib folder where qrcode.class file is located
Step 6 . Import the java class qrcode in the RDF

Step 7 . Create a Formula column in the Reports calling the Java Code :

function CF_1Formula return Char is
image_file_name VARCHAR2(1000);
qrcode.generate (:DATA , image_file_name);

Step 8 . In the Reports layout , create a Field with the properties :

Source : <The Formula Column created in Step 7>
Read from File : Yes
File Format : Image
Step 9 . Modify the Reports Server configuration in order to add/modify the classPath Reports engine attribute :

<engine minEngine=”1″ maxIdle=”30″ maxEngine=”1″ id=”rwEng” engLife=”50″ class=”oracle.reports.engine.EngineImpl” classPath=”D:\oracle\fmw11r1\oracle_fr\reports\jlib;D:\oracle\fmw11r1\oracle_fr\reports\jlib\core-1.7.jar;D:\oracle\fmw11r1\oracle_fr\reports\jlib\javase-1.7.jar;D:\oracle\fmw11r1\oracle_fr\reports\jlib\qrgen-1.2.jar”>

The classPath attribute value should contain (at least)  the 3 jar files required (core-1.7.jar , javase-1.7.jar and qrgen-1.2.jar) and the directory containing the class qrcode.class created in Step 3.

If you want to test the RDF in the Reports Builder , the 3 jar files required (core-1.7.jar , javase-1.7.jar and qrgen-1.2.jar) and the directory containing the class qrcode.class created in Step 3 must be added (if necessary) to REPORTS_CLASSPATH

The file in attachment contains the files : : the java source of the class qrcode
qrcode.class : the class qrcode
qrcode.rdf  : a RDF in which qrcode.class has been imported and a Formula has been created to call this java code.
qrcode.pdf : a PDF generated using qrcode.rdf


NOTE:1269490.1 – Support For 2D Barcode in Oracle Reports
NOTE:1554189.1 – Is it Supported to Upgrade the JDK in the ORACLE_HOME of an 11gR1 or 11gR2 Forms & Reports Installation to JDK 1.7.0_XX ?
NOTE:278044.1 – How to Debug REP-1401 when Executing Reports with Barcode Java Code


Oracle REP-0300, REP-0069, REP-57054, REP-300


Forcing NLS_NUMERIC_CHARACTERS to: ‘.,’ for XDO processing

APPLLCSP Environment Variable set to :

Current NLS_LANG and NLS_NUMERIC_CHARACTERS Environment Variables are :


Enter Password:
REP-0300: ORACLE error occurred.
REP-0069: Internal error
REP-57054: In-process job terminated:Terminated with error:
REP-300: ORACLE error occurred.



Check the data type of your parameter in RDF it is date or not and what was the format mask.