Generate EAN Barcode in Java.

EAN barcode is widely used in international trading to identify the details of different products. The EAN barcode is popular because of its efficiency as it can be processed faster, is less error-prone, and different variations exist for different scenarios. In certain cases, you may need to create an EAN code. Accordingly, this article explains how to create an EAN barcode programmatically in Java.

Java EAN Barcode Generator API - Free Download

Aspose.BarCode for Java API supports creating or scanning many types of barcodes. You can easily set it up by accessing it from the downloads section or use the configurations below in your pom.xml file to enable it from Aspose Repository.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>http://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-barcode</artifactId>
    <version>22.9</version>
</dependency>

Generate EAN 13 Barcode in Java

The following steps elaborate on how to generate an EAN barcode programmatically in Java:

  1. Initialize an object of BarcodeGenerator class.
  2. Set the size in the number of pixels.
  3. Save the output EAN 13 barcode as an image.

The following code snippet demonstrates how to generate an EAN barcode programmatically in Java:

Generate EAN 5 with Supplement Data in Java

You can append additional digits to reflect specific information into the barcode. The following steps show how to generate EAN 5 barcode by appending digits to the EAN 13 code in Java.

  1. Create an instance of BarcodeGenerator class and set the EncodeType.
  2. Set the supplement space and supplement data.
  3. Save the output EAN 5 code as an image.

The code sample below shows how to generate an EAN 5 code with supplement data in Java:

The following image depicts the sample output of an EAN 5 code containing the supplement data:

EAN 5 Supplement Java

Get a Free License

Interested to evaluate the API without any evaluation limitations? Request a free temporary license now to test the API to its full capacity.

Conclusion

In this article, you have understood how to generate an EAN barcode programmatically in Java. Moreover, the details to create EAN code with supplement data like EAN 5 and EAN 2 is also explained. Furthermore, you can find more details about other features of the API by visiting the documentation section. Please feel free to write to us at forum if you need to discuss any of your concerns.

See Also