Barcode Fonts, Components, ActiveX and .NET Windows Forms Controls, Java Servlets, 
DLLs and Barcode Scanners., Inc., Computers Hardware, Software & Services, Tampa, FL   This site chose the Norton Secured Seal to promote trust online with consumers.    View your cart in the IDAutomation Store   

Home > Barcode Components > Java Barcode Package > Oracle Reports Barcode Implementation

Creating Barcodes in Oracle using JavaIBM Partner Logo

This Oracle Reports tutorial creates barcodes in a report using the IDAutomation Java Barcode Package and a comma delimited file as a database source. To retrieve data from other database sources such as an Oracle Database Server, please refer to the documentation in Oracle Reports.

Order the JavaBeans, Applets & Download Demo of Barcode Generator for .NET Barcode Forms Control & DLL Support Forum

  • Oracle Reports 9i or greater

This tutorial will use the class library of the IDAutomation Linear barcode Java .jar file to create temporary jpeg images of Code 128 barcodes in a report. After the barcodes are generated, the report engine deletes the temporary images. To generate 2D barcodes, simply substitute the class used in this tutorial. For example, instead of using com.idautomation.linear.encoder, use com.idautomation.datamatrix.encoder for a Data Matrix barcode.

Java Barcode Jars & API Symbology Information Class File Path Create Object
LinearBarCode.jar Code 39, Extended Code 39, Code 128, Code 128 auto, AI detection for GS1-128, Interleaved 2 of 5, Codabar, UPC-A, UPC-E, MSI, EAN-8, EAN-13, Code 11, Code 93, Industrial 2 of 5, USPS Intelligent Mail IMb, Postnet & Planet. com.idautomation.linear.encoder BarcodeObject :=
IDADataBar.jar GS1 DataBar, Stacked, Truncated, Stacked Omni-directional, Limited, Expanded, Expanded Stacked Omni-directional, Composite components, PDF417, MicroPDF417, UPC-A, UPC-E, EAN-13, EAN-8, GS1-128 and Code 128. Composite components are provided with all linear symbologies. com.idautomation.databar.encoder BarcodeObject :=
IDAAztec.jar Aztec matrix generation with automatic mode selection and GS1 compatibility. AIM Specification ANSI/AIM BC13 ISS Aztec Code. com.idautomation.aztec.encoder BarcodeObject :=
IDADataMatrix.jar Data Matrix with ECC200, ASCII, text, C40 and Base256 encoding, Includes support for US DOD UID and macro codeword 236 and 237 ISO/IEC 15434 formats com.idautomation.datamatrix.encoder BarcodeObject := 
IDAMaxiCode.jar MaxiCode with structured append, UPS encoding and mode 2-6 support. com.idautomation.maxicode.encoder BarcodeObject :=
IDAPDF417.jar PDF417 with EC levels 1 to 8, text and binary encoding. com.idautomation.pdf417.encoder BarcodeObject :=
IDAQRCode.jar QRCode with support for Byte, Numeric, and Alpha-numeric encoding modes. Automatic Version selection. com.idautomation.qrcode.encoder BarcodeObject :=

Tutorial on how to access the JAR Properties in the API.

Step 1. Creating a report using a comma-delimited data source
  1. Download and save the text files, ProductInv.txt and InventoryPDS.txt, required for implementing this example here. (InventoryPDS.txt is the pluggable data source definition file and ProductInv.txt is the file containing the data that will be included in the report.)
    download now button
  2. In a text editor (such as Notepad), Open InventoryPDS.txt. Make sure Reports Builder is closed.
  3. Start another text editor session and Open textpds.conf. This file will be in the Oracle_Home/reports/conf directory. This file enables Reports Builder to recognize ProductInv.txt as a Pluggable Data Source (PDS). NOTE: The Oracle_Home directory path is the home directory of all Oracle applications and was set at the time Oracle Reports was installed.)
  4. Copy the text from InventoryPDS.txt to textpds.conf. This data should be copied before the line "</textPDS>".
  5. Save and close both text files.
  6. Start Reports Builder.
  7. Ensuring the "Use Report Wizard" option is highlighted, click OK.
  8. If the "Welcome to the Report Wizard" screen is displayed, click OK.
  9. Select "Create Paper Layout Only", click Next.
  10. Title the report "Product Inventory". Select the "Group Above" option. Click Next.
  11. In the Data Source step, Highlight "Text Query", click Next.
  12. Click the Query Definition button.
  13. Find ProdInvCSV in the drop-down list under Data Definition.
  14. Click the Browse button under Data Source. Navigate to the location of ProductInv.txt. Ensure that the Files of Type box reads TXT files. Click OK in the Define Text Query box.
  15. Click Next on the "Data Source Definition" page of the Report Wizard.
  16. Move Category to the "Group Fields" list by highlighting Category and clicking the right arrow (>). Click Next.
  17. Click the double right arrows (>>) to move all fields to the list of Displayed Fields. Click Next.
  18. Click Next on the Totals page of the Wizard.
  19. Click Next of the Labels page of the Wizard.
  20. Select the color for the Predefined Template of the report. Click Next.
  21. Click Finish. The report should be available in design view.
  22. Save the report as Inventory.jsp.
Step 2. Adding the IDAutomation Barcode Java Component to Oracle Reports
  1. Ensure Oracle Reports is not running.
  2. Save LinearBarCode.jar to an easy-to-remember location. For example, C:\ClassPath. *Alternate Jar Symbologies
  3. Update the REPORTS_CLASSPATH environment variable to include the JAR file.
    1. For Windows systems: Update the REPORTS_CLASSPATH registry entry for Oracle Reports. This registry entry tells Oracle Reports where to find .jar files containing classes that Oracle Reports will be able to use. NOTE: This step requires updating the Windows registry. IDAutomation recommends creating a backup of the registry before continuing.
      Search the registry for REPORTS_CLASSPATH key value. Double-click REPORTS_CLASSPATH. Edit the value by adding the name of the full filename and path of the jar file, e.g. C:\ClassPath\LinearBarCode.jar;. Ensure there is a semi-colon at the end. Click OK and close the registry.
    2. For Linux and UNIX systems: update and save the REPORTS_CLASSPATH environment variable.
  4. Open Oracle Reports.
  5. Select "Open an Existing Report". Click OK.
  6. Select Inventory.rdf. Click Open.
  7. On the Program menu item, click Import Java Classes.
  8. Navigate through to COM | IDAutomation | Linear | Barcode. Click Import.
  9. Navigate through to COM | IDAutomation | Linear | Encoder | barCodeEncoder. Click Import.
  10. In Object Navigator, double click the icon next to Data Model to open the Data Model editor.
    A display similar to the following image should show up.
    Oracle report editor
  11. Click on the Formula Column object in the toolbar.
  12. Draw a Formula Column object in the G_Product pane of the Data Model viewer.
    Inventory Report Editor
  13. Double click the new Formula Column field to bring up the Property Inspector window.
  14. Change the Data Type property to Character.
  15. Click the formula box next to the PL/SQL Formula property in the Property Inspector. This will open the PL/SQL editor.
  16. Replace the code between the function definition and 'end;' with the following code:
    /*name of temp file. For 1D barcodes, set to VarChar2(250). For 2D barcodes, set to VarChar2(500).*/

    ImageFile VarChar2(250);
    /*object containing barcode properties*/
    BarcodeObject ORA_JAVA.JOBJECT;
    /*object that creates jpeg of barcode based on BarcodeObject*/
    BarcodeEncoderObject ORA_JAVA.JOBJECT;
    /*Get a temporary file name for the jpeg*/
    /*On Solaris Unix, use the following code to create the temp file: ImageFile := srw.create_temporary_filename() || '.jpg'; */
    imageFile := srw.create_temporary_filename();
    /*Create the barcode object. This example uses the LinearBarCode.jar*/
    BarcodeObject :=;
    /*Set the symbology. This property setSymbologyID is only valid for the LinearBarCode.jar*/
    BarCode.setSymbologyID(BarcodeObject, BarCode.CODE128);
    /*set the data to encode*/
    BarCode.setDataToEncode(BarcodeObject, to_char(:ProductID));
    /*Create the jpeg*/
    BarcodeEncoderObject :=, 'JPEG',ImageFile);
    /*If, for some reason, the barcode is not created, return null
    otherwise, return the name of the barcode image jpeg that was
    created */

    if ORA_JAVA.IS_NULL(BarcodeEncoderObject) then
    end if;

    Please note that this is the area where other properties, i.e. Left Margin, Top Margin, Human Readable Text Visibility, etc., of the barcode image can be set. To size the barcode, use the methods setXDimensionCM to increase the width (X dimension) and setBarHeightCM to increase the height.
    For other options, please refer to the JavaBean properties in the user manual of the product. Online versions of the manuals are located here.
  17. Compile the code in the PL/SQL editor to ensure there are no errors and close the PL/SQL window.
  18. Open the Page Layout for the report by double clicking the icon next to Paper Layout in Object Navigator.
  19. Ensuring that the table is selected in the Paper Layout, drag a Field Object from the Toolbox onto the form. The display should look similar to the image below.
  20. Double-click the new Formula Field, F_1, to bring up the Property Inspector. Set the following properties:
     --Select CF_1 from the dropdown list for the Source Property.
     --Select Character from the dropdown list for the DataType Property.
     --Set the ReadFromFile Property to 'Yes'.
     --Set the FileFormat Property to Image.
  21. Save the report.
  22. Select Compile | All option from the Program menu. At this point the report should be ready to preview.
  23. Select Program | Run Paper Layout from the Report Builder menu.
  24. Make adjustments to the layout, formatting, and size of the fields, if necessary, in the report using the Report Layout Editor. The final report should look similar to the following image:
    Barcode report

Related Documents and Keywords:

View the product index to obtain a list of all IDAutomation's products.

Back to Top

 ©Copyright 2017, All Rights Reserved. Legal Notices.

 Barcode Fonts | Components | Scanners | Support | Contact Us

Training Videos on YouTube  Join us on Google Plus  Join us on LinkedIn  Follow us on Twitter  Like us on Facebook
Over 70% of Fortune 100 companies use IDAutomation's products to automate their businesses.