SmartDongle Java Native Interface for libusb

Release 0.14.0
June 19, 2008

This code has been tested on the following systems:

  • Linux (2.4.x and 2.6.x)
  • Mac OS X (both Intel Mac and PowerPC Mac)

    current code untested on Solaris and FreeBSD


    Download


    Contents


    Note

    If SmartDongle access returns error codes 41 or 42, the problem may be that the mode of the dynamic SmartDongle device files in /proc/bus/usb/ and /dev/bus/usb/ do not allow user access.
    As of linux kernel version 2.6.x, permissions can be set with hal facilities.
    Refer to src/HAL/README.txt

    Building the Examples

    1. You must have Java Platform Standard Edition Development Kit and Java Standard Edition Runtime Environment installed.

    2. Download and unzip: SmartDongle JNI Examples.zip

    3. Edit the example code to use your unique key values, for example:
      private final static long p1 = 0xEC6CC589AEFD1E75L;
      private final static long p2 = 0xFCEC0A6A82747B3FL;

    4. Edit build.cmd file in the corresponding example's directory:

      • This variable corresponds to your main class name
        MAIN_CLASSNAME=Example1

      • This variable corresponds to your full qualified class name
        FULLY_QUALIFIED_CLASSNAME=Java_Example1
        The fully qualified class name is required for the JNI function names. If this is an incorrect fully qualified classname, executing example1 will produce this error:
        Exception in thread "main" java.lang.UnsatisfiedLinkError: smartDongleWrite

      • Edit these paths:

        The absolute path to the project directory such as: WORKING_DIR="/home/your_home_directory/SmartDongle JNI Examples"

        Path Java Development kit binaries
        JAVA_HOME=/opt/sun-jdk-1.5.0.13

        Path to GNU gcc complier:
        CC=/usr/bin/gcc

    5. Running build.cmd script, this will automate these steps:

      • Initial compilation of the main class and creation of JNI C header file.
      • SmartDongle interface source files are processed and SmartDongle JNI library (libuskjni.so) is compiled using your fully qualified class name (FULLY_QUALIFIED_CLASSNAME).
      • Computation of SHA fingerprint of libuskjni.so
      • The SmartDongle code in the main class file is updated with the SHA fingerprint.
      • The main class is then recompiled.