How to generate QR Code in Java

QRGen library provides an API to generate the QR Code in a Java application. It is built on the top of ZXing. Add the following dependency to your project’s pom.xml file.


P.S. The QRGen library is no longer deployed to Maven Central, but it’s available on

The sample of QR Code generated through QRGen library:

How to generate QR Code in Java
package org.websparrow;

import net.glxn.qrgen.javase.QRCode;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;

public class QRCodeDemo {

  private static final String BARCODE_TEXT = "";

  public static void main(String[] args) {

    try (ByteArrayOutputStream bos = QRCode.from(BARCODE_TEXT).withSize(250, 250).stream(); ) {

      ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());

      ImageIO.write(, "PNG", new File("QRCode.png"));

      System.out.println("QR Code successfully generated");
    } catch (IOException e) {


  1. QRGen- Github
  2. QRGen- JitPack

Similar Posts

About the Author

Atul Rai
I love sharing my experiments and ideas with everyone by writing articles on the latest technological trends. Read all published posts by Atul Rai.