Friday, May 20, 2011

Building Zxing to Use in Blackberry Java Development

Zxing is a open source tools to read/writer various format of Barcode. Currently I'm using it for my blackberry java application.

This tutorials is about how to build zxing core using Ant.
  1. Dowloand zxing from http://code.google.com/p/zxing/
  2. Download Apache Ant http://ant.apache.org/
  3. Extract the Apache ant to a folder e.g. C:\apache-ant-1.8.2
  4. Extract the zxing (I'm using version 1.6) to a folder e.g C:\zxing-1.6
  5. Type this to build zxing core.jar

    C:\zxing-1.6> ant -f core/build.xml

    Make sure ant.bat is accessible from System Path, or you can type full directory such as
    C:\apache-ant-1.8.2\bin\ant instead of ant.
  6. Build zxing j2me.jar
    Make sure you have set the WTK-home in the build.properties
    (check C:\zxing-1.6\build.properties)

    WTK-home=D:\\Java_ME_platform_SDK_3.0

    (this is the location of Java ME SDK 3.0 installation folder)

    Set the location of Proguard.jar

    proguard-jar=D:\\proguard4.6\\proguard4.6\\lib\\proguard.jar



    Note: notice that in Java ME SDK 3.0 untuk JSR135 Mobile Media API (MMAPI) using JSR135_1.1 version, and there's no JSR135_1.2 version.

    So, edit build.xml for javame build (check C:\zxing-1.6\javame\build.xml)
    REPLACE jsr135_1.2.jar with jsr135_1.1.jar

    Then type in the console: 

    C:\zxing-1.6> ant -f javame/build.xml -lib D:\Java_ME_platform_SDK_3.0\lib;D:\proguard4.6\lib
  7. Generate zxing for rim client (rim build)

    zxing-1.6 using preverify1.1.exe, but Java ME SDK 3.0 only have preverify.exe

    edit rim/build.xml
    Find text preverify1.1, and replace with preverify

    Type in the console:

    C:\zxing-1.6> ant -f rim/build.xml


    Note: -lib in the ant command is used for specifying the classpath. For multiple classpath, we can use semicolon (;)
    See http://ant.apache.org/manual/running.html for more details

4 comments:

QRScanner said...

Hi Wen,

Getting error
Target "D:\proguard4.6\lib" does not exist in the project "javame".

Even though I have placed the proguard.jar at the same path. And also uncommented the WTK-Home and proguard-jar params in build properties of zxing. FYI I am using zxing 1.7.

QRScanner said...

Resolved the above by removing the D:\proguard4.6\lib and got it working. thanks again for the excellent post.

Unknown said...

Hey, nice site you have here! Keep up the excellent work!



Blackberry Development

Unknown said...

Thank you for your tips. I need such a tutorial about generate qrcode in java application. Your guide is good and helpful. Hope I can learn more from your other articles as well.
Best regards.