Example of generating a QR code for your website in Java

Source: Internet
Author: User

In the age of the Internet of Things, the QR code is a very important thing, now no matter what things have to make a two-dimensional code sign, lest the outdated, the policeman did not use two-dimensional code recognition. Perhaps one day zoning card or hukou will be used to identify the two-dimensional code. Today's whim, see others have added two-dimensional code for their blog, I also want to make a test.

Mainly used to achieve two points:
1. Generate the QR code of any text.
2. Add an image to the middle of the QR code.

First we have to download the Zxing.jar package, I use the 3.0 version of the core package
: Now you have migrated to Github:https://github.com/zxing/zxing/wiki/getting-started-developing, and of course you can download the jar package from the MAVEN repository:/http Central.maven.org/maven2/com/google/zxing/core/

Build a test project based on Zxing. Generate two-dimensional code



The key code is: Bufferedimageluminancesource.java and Qrcodeutil.java, where the main method of the test is in Qrcodeutil.java.

Create a QR code with no logo

 Public Static void Main (string[] args) throws Exception {        "http://www.yihaomen.com";         "" " C:/barcode " true );    }

Run this test method, generated QR code without logo, the style is as follows:


I'm interested in scanning with a cellphone.

Create a QR code with logo
Logo can be used with their own avatar, or a picture of their favorite can be, using the following code

 Public Static void Main (string[] args) throws Exception {        "http://www.yihaomen.com";         " c:/me.jpg " " C:/barcode " true );    }

The only difference is that on the basis of the previous designation of the address of the logo, the test is used in the C-drive picture file


Scan with a mobile phone, can appear to appear in the text, click on to enter their own site, looks good, the entire source code, provided in the download test:
Java Barcode Sample

This article is from: http://www.yihaomen.com/, the original address: http://www.yihaomen.com/article/java/491.htm, thank the original author to share.

Example of generating a QR code for your website in Java

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.