Create QR Code in Java.

QR codes are popularly used to share important information. For different requirements, you might want to create a QR code in your solutions or applications. Accordingly, this article elaborates how to create a QR Code programmatically in Java.

Java API Installation to Generate QR Code

You need to install Aspose.BarCode for Java API which enables you to work with various type of barcodes. Simply download the relevant JAR files or access it with the following configurations in the pom.xml file to configure it from the 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.8</version>
</dependency>

Create QR Code in Java

You can create a QR Code with the following steps:

  1. Create an object of the BarcodeGenerator class and mention the input text along with the EncodeType.
  2. Set types of encoding and version of QR code.
  3. Generate the QR Code and export the generated code as a PNG image.

The following sample code demonstrates how to create a QR Code in Java:

Generate QR Code with ForceQR Encoding in Java

You need to follow the steps below to create a ForceQR type of QR code in Java.

  1. Create an instance of the BarcodeGenerator class and specify the EncodeType and the input text.
  2. Set the encoding type and version of the desired QR Code.
  3. Write the output file containing the code as a PNG image.

The following code sample explains how to generate a QR code with ForceQR encoding in Java:

Get a Free License

You may evaluate the API without any watermarks or evaluation limitations by requesting a free temporary license.

Conclusion

In this article, you have explored how to generate a QR Code of various kinds, versions, etc. based on your requirements. The code sample shows the whole process to generate QR Code programmatically in java. Moreover, you may take a look at the documentation space to check many other variations and features supported by Aspose.BarCode for Java API. In case of any queries, please feel free to reach out to us via the forum.

See Also