pikopong

it's all about knowledge

Reading MyKad in Windows

with 27 comments

For my first post in this blog, I decided to give out an example application to read MyKad which is written in Java. This application has successfully read:

  1. Old and new IC number
  2. Name
  3. Sex
  4. Date of birth
  5. Birth place
  6. Nationality
  7. Race
  8. Religion
  9. Address
  10. Photo

Do take note that for the photo part, it is not completely bug free, I’ll fix it when I got time which may not be happening :) There are a few things that I need you take note first:

  • Almost 70% codes of this application are not written by me. I’m merely putting pieces together from multiple references in order to read the MyKad.
  • Main credit should be given to Xenon who somehow managed to reverse engineered MyKad APDU so that we can read it without needs to pay a single cent for the SDK.
  • Don’t expect a perfect code here since it’s my first time writing Java codes after 3 years and I don’t see any needs to upgrade it, at least for now. But you can be sure that it’s working at the time of this post is written.
  • Even though it’s written in Java, it can be a guide for you to write in your own favorite programming language.
  • This application only reads data from Jabatan Pendaftaran Negara (JPN).

These are the system environments that I use to run this app:

  1. JDK 6 Update 2 (JDK 5 should be working just fine).
  2. Windows XP.
  3. Netbeans 5.5 (you may need to update the GUI Builder Pack to the beta version if you want to edit the GUI, however it’s recommended you use the latest version).
  4. A smart card reader, I use Athena (got Linux support). Other brand will do, just make sure the driver is installed correctly.

Follow these steps to read your first MyKad:

  1. First thing first, you need to download Windows binary of JPC/SC Java API.
  2. Get the Netbeans project file here.
  3. You must include jpcsc.jar as the library. You can get the file from Step 1.
  4. You must also put jpcsc.dll into your main project folder and if you want to distribute the application, you MUST put it together with your main jar file. You can also get it from Step 1.
  5. Plug in your reader.
  6. Run the application (either directly or from Netbeans).
  7. Insert your MyKad.
  8. Wait till the app finished reading it.
  9. A GUI will popup presenting your MyKad data.
  10. If no data is showing, it is possible that your MyKad chip is spoiled that is if you’ve done everything correctly. It will only take 14 days to get a new one.

If you have any question regarding the Java itself, you can ask in the comment section, but if you got question about the APDU commands, I suggest you read this post by Xenon, the explanations given are very detail. There’s also a simple application made by him to read MyKad written in C.

Screenshot of the interface:

GUI

Summarize links of all files in this post:

Stay tune for the Linux version :)

Update 1: Linux version is available here.
Update 2: Read MyKad using Visual Basic

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • PDF
  • Print
  • Reddit
  • Slashdot
  • Technorati
  • Twitter

Related Posts

Written by amree

January 5th, 2008 at 12:35 am

Posted in programming

Tagged with , ,

27 Responses to 'Reading MyKad in Windows'

Subscribe to comments with RSS or TrackBack to 'Reading MyKad in Windows'.

  1. OK.. Cun tq.. blh kasi aku coding utk vb 6 tak camne nak baca reader???

    TQ

    MasTerjiNo Gravatar

    10 Jan 08 at 05:00 PM

  2. Sorry, can’t help you on that, I don’t know VB at the moment, but maybe you can refer to Xenon Console App for a reference

    amreeNo Gravatar

    11 Jan 08 at 08:34 PM

  3. amreeNo Gravatar

    28 May 08 at 12:35 AM

  4. 1. instead of doing this way, is there any possibilities invoke it using javascript?

    2. how i’m going to include jpcsc.jar as the library?do i need to install netbeans?

    senNo Gravatar

    30 Jun 08 at 04:04 PM

  5. @sen

    You’ve to understand that Java is not the same as JavaScript. To implement MyKad reading using web based application, you might consider using Java Applet (google about it), however, the reader must be installed correctly at the client PC.

    By the way, Netbeans is just an editor, just like Notepad. You don’t need it to run Java apps. But of course, you need at least Java Runtime Environment (JRE) to run Java application.

    amreeNo Gravatar

    1 Jul 08 at 02:57 PM

  6. thanks a million amree.
    i’d extend it to applet. however, my servlet seem can’t read the applet.

    this error has occured:

    and

    why?can you help me fix this.
    thanks

    senNo Gravatar

    2 Jul 08 at 07:18 AM

  7. sorry, the error didnt display again :

    classNotFoundException.sc.MainApplet.class

    and

    NoClassDefFoundException: com/linuxnet/jpcsc/PCSCException

    thanks in advance..

    thanks in advance

    senNo Gravatar

    3 Jul 08 at 10:12 AM

  8. @sen

    I’m not really sure about the error since I have no experience in creating applet. Maybe when I’m free, I’ll setup a demo using applet, till then, Google is your friend :) Good luck !

    amreeNo Gravatar

    4 Jul 08 at 06:39 PM

  9. great! anyway how can i display the thumb print?

    aizulNo Gravatar

    12 Sep 08 at 11:15 AM

  10. @aizul

    Sorry, haven’t venture much into the thumb print things, if I did, I’ll post the information :)

    amreeNo Gravatar

    12 Sep 08 at 05:36 PM

  11. it’s ok. i am trying to do it in an applet. i am stuck with the dll loading.

    aizulNo Gravatar

    14 Sep 08 at 02:47 AM

  12. It’s no exageration! Your programme using VB is simply wonderful. You get to capture the info and the image beautifully well using ACS card reader. It is not just VB (Visual Basic) but VBVB, VB (Very Best) VB (Visual Basic). Thanks to you and Xenon. Is there a way of bringing in your creation to other database programme like Access to capture and save it to the database. I am no programmer. This will help a lot for associations and organizations to register delegates or participants with minimal manual effort.

    Dr RatnaNo Gravatar

    15 Oct 08 at 02:48 PM

  13. @Dr Ratna

    Correction, the VB is not my program (it was Xenon’s), hence, I can’t be really helpful in Visual Basic department :) However, I’m not sure if it’s possible to ‘insert’ the program into Microsoft Access. But it’s definitely possible to create a program with Visual Studio and using Microsoft Access as the database.

    amreeNo Gravatar

    18 Oct 08 at 02:34 PM

  14. Thanks for your reply. As I have informed, I am no programmer. Can Xenon be of help?

    Dr RatnaNo Gravatar

    20 Oct 08 at 06:32 PM

  15. @Dr Ratna

    Please check your email for Xenon’s contact.

    amreeNo Gravatar

    20 Oct 08 at 08:13 PM

  16. cool

    dotaNo Gravatar

    27 Feb 09 at 04:16 AM

  17. Hello amree, what does this mean?

    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/linuxnet/jpcsc/PCSCException
            at sc.Main.<init>(Main.java:14)
            at sc.Main$2.run(Main.java:311)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

    dotaNo Gravatar

    22 Mar 09 at 05:52 PM

  18. @dota

    Check your email

    amreeNo Gravatar

    24 Mar 09 at 09:00 AM

  19. Is This Just For Fun

    danialNo Gravatar

    10 Apr 09 at 11:18 AM

  20. Sorry, i also face same problem :-
    NoClassDefFoundException: com/linuxnet/jpcsc/PCSCException
    can you help me, Thanks

    ahfeiNo Gravatar

    17 Jun 09 at 09:40 AM

  21. @ahfel

    You need to link jpcsc library correctly into your project

    amreeNo Gravatar

    25 Jun 09 at 02:15 PM

  22. Hi amree.
    As u have given in the det I have downloaded JPC/SC Java API, and added the library jpcsc.jar and its reference DLL jpcsc.dll.The code is executing without any exceptions and initializing the reader and returning the Reader Name : Cardman OMNIKEY 5×21 0 but in next step GetStatusChange its going inside the loop and the condition is not satisfying to come out.
    Am using the OMNIKEY 5321 Reader and Mifare 1k Card.

    can u plz give me some solution for this.

    AnoopNo Gravatar

    6 Aug 09 at 01:37 PM

  23. How can I read mykas PKI?
    what code should I use?

    wanNo Gravatar

    24 Oct 09 at 03:37 PM

  24. when will the finger print be available? because i have a project that requires to do finger print verification from mykad.

    raption83No Gravatar

    14 Jan 10 at 02:13 PM

  25. Hi amree,

    I do have this error:0x8010002e,Cannot find a smart card reader.

    Any idea?

    Many Thanks.

    JavaNoobNo Gravatar

    2 Jun 10 at 10:54 PM

  26. @JavaNoob

    It seems like your reader has not been detected yet. Make sure it’s in your Device Manager list. For my reader, if everything is OK, it will light up (meaning it’s ready to be used). Maybe you should install driver or something.

    amreeNo Gravatar

    8 Jun 10 at 11:48 AM

  27. Hi amree,

    Ya, it’s detected as – CP210x USB to UART Bridge Controller in Device Manager. It should be fine theoretically. hmm….

    JavaNoobNo Gravatar

    11 Jun 10 at 12:42 AM

Leave a Reply