Simple Java QR Code Generator Example

You may also like...

  • Caleb Bankole Olojo

    It doesn’t work for me. Keeps throwing error.

    Exception in thread “main” java.lang.NoSuchMethodError: com.google.zxing.Writer.encode(Ljava/lang/String;Lcom/google/zxing/BarcodeFormat;IILjava/util/Map;)Lcom/google/zxing/common/BitMatrix;
    at net.glxn.qrgen.QRCode.createMatrix(QRCode.java:206)
    at net.glxn.qrgen.QRCode.writeToStream(QRCode.java:202)
    at net.glxn.qrgen.QRCode.stream(QRCode.java:180)
    at parkingSoft.QrTest2.main(QrTest2.java:18)

    Please help. Thanks

    • For those getting the NoSuchMethodError, you probably didn’t include the correct dependencies to your project.
      Make sure the net.glxn.qrgen: javase:2.0 is on your classpath.
      This version includes
      – com.google.zxing:javae:3.1.0
      – com.google.zxing:core:3.1.0
      – net.glxn.grgen:core:2.0
      – org.jfree:jfreesvg:2.1

      Cheers,
      Memorynotfound