Introduction
This document covers how to create a simple IMEI validator application using Java Swing.
What is IMEI Number
IMEI stands for International Mobile Equipment Identity. IMEI is used to identify a mobile device when it is connected to a network. Each GSM, CDMA or satellite mobiles have unique IMEI number. This number will be printed in the device inside the battery component. User can find his device IMEI number by calling "*#06#". IMEI is a 15 digit number and the last digit is called as "Check Digit" and it can be identified by using Luhn Algorithm.
Luhn Algorithm
- Double the value of every second digit from the right end(first right will be check digit number).
- Add the individual digits comprising both the products from step (1) and unaffected digits in the original number.
- If the total modulo 10 is equal to 0, then the number is valid, else it is not valid.
A simple example: IMEI no of mobile-354557030810924
Step 1
Step 2
3+1+0+4+1+0+5+1+4+0+6+0+1+6+1+0+9+4+4=50
Step 3
50%10=0. So above number is valid number.
IMEI Validator Using Java Swing
- Open Eclipse and create new Java project.
- Name the project as ImeiValidator and click Finish.
- Now open the Package Explorer and right-click on ImeiValidator.
- Create a new class called Imeivalidator:
- Write the following code in the class:
- Now run the application using Run -> Run As -> Java Application.
- The following window will be displayed:
- Enter the IMEI number and click "Click" as shown below:
References
- http://en.wikipedia.org/wiki/Luhn_algorithm
- http://en.wikipedia.org/wiki/International_Mobile_Equipment_Identity