IDAutomation.com, Inc.

Your Source for Quality Symbology

[IDAutomation.com Home Page]

Linear Java Bar Code Package

Barcoding with the BarCode class:

This section explains the main configuration parameters of the BarCode class. This class is a descendant of java.awt.Canvas and you can therefore use it in any java container. The names in parenthesis are the names of the applet parameters. For information on Java bean operation please review BeanInfo.html. You may also wish to review the index of fields and methods. To hide the text below the barcode, make the "fontColor" the same as the "backColor".

Servlet Operation and JPEG or GIF File Encoder Example

Before you can create a GIF or JPEG file with the Java Package, you must make sure you meet the following requirements:

  1. Place the jar or class files in the CLASSPATH - in Windows, this is accomplished by modifying the CLASSPATH environment variable to include the full path to the JAR file. For example, the following will add LinearBarCode.jar to the classpath:
    SET CLASSPATH=.;c:\java\classroot\;c:\jars\LinearBarCode.jar
    You can also extract the files in the JAR files to the classpath root, making sure the proper directories defined in the JAR are created.
  2. Use JDK 1.2 or above - the encoder requires Java 2 or JDK 1.2 or above to create the GIF or JPEG files. This is a requirement of the encoder that creates the files, not the class library.
  3. Java.awt GUI functions must be available in your environment - this is not usually an issue with Windows NT and Windows 2000 servers. In UNIX, if your Java environment has the java.awt library stripped out, then you will be unable to use our Java products. If your UNIX server does not have an X-Window environment, you must connect to a remote X Server or install the X Windows environment and run an X Windows session.

How to create a GIF or JPEG file:

This is a very simple example of the Java source code used to create a GIF file from the Linear Barcode Package.

How to use the Servlet:

  1. Install the appropriate servlet server code on your server and make sure it is in the CLASSPATH also. For example:
    SET CLASSPATH=.;c:\java\classroot\;c:\jars\LinearBarCode.jar;c:\jsdk2.1\server.jar;c:\jsdk2.1\servlet.jar
  2. Per the JSDK instructions, we edit servlets.properties to include the following statement:
    LinearServlet.code=com.idautomation.linear.IDAutomationServlet
  3. Next, we start the servlet server by executing C:\jsdk2.1\startserver.bat.
  4. After the servlet server is started, we can type the following code into our browser and specify applet parameters to create the barcode. This URL creates the a barcode encoding "12345678" with a height if .8CM:
    http://localhost:8080/examples/servlet/LinearServlet?BARCODE=12345678&BAR_HEIGHT=.8
  5. We can also create a barcode within webpages and HTML forms by using an IMG tag, for example:
    <img src="http://localhost:8080/examples/servlet/LinearServlet?HEIGHT=80&WIDTH=170&BARCODE=12345678&BAR_HEIGHT=.8">
    Notice also in the above code that the HEIGHT and BAR_HEIGHT are different. The HEIGHT and WIDTH parameter should be set to the maximum allowed barcode size within a form.
  6. Other methods of servlet operation can be accomplished by advanced programmers that modify the servlet source code we provide. However, these methods cannot be supported by tech support.

How to create the barcode in a java.awt.Image object

The following code illustrates how you can create a barcode in a java.awt.Image object:

BarCode bc=new BarCode();
bc.setSize(400,200); // important - set the size

// create image
java.awt.image.BufferedImage image = new java.awt.image.BufferedImage( bc.getSize().width,bc.getSize().height,java.awt.image.BufferedImage.TYPE_BYTE_INDEXED );

// get graphic context of image
java.awt.Graphics imgGraphics = image.createGraphics();

// paint barcode in graphics context of image
bc.paint(imgGraphics );

How to use the checkCharacter (CHECK_BAR) field:

If you are supplying the code with the check digit already calculated, you must set CHECK_CHAR to N (this is the default). If you want the software to calculate the checksum for you, you must set CHECK_CHAR to Y.

EAN and UPC symbologies have a fixed length, therefore you only have the following possibilities:

BCApplet

You can use BCApplet to display barcodes in your HTML pages. Some parameters of the applet have a special format:

Example of how to use the applet:

You can provide the parameters in the Applet PARAM tag or you can also do it from Javascript. For example, the following code set a new value for the barcode:

Barcodes types

The following is a short description of some of the barcode types:

 

For more information about the barcode symbologies, please visit our BizFonts.com site and select the symbology.