Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

HOW TO: Call a LEADTOOLS API Function from Java
Started by GregR at 10-12-2006 17:03. Topic has 0 replies.

Print Search « Previous Thread Next Thread »
  10-12-2006, 17:03
GregR is not online. Last active: 8/29/2008 2:25:56 PM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,542
HOW TO: Call a LEADTOOLS API Function from Java

Attachment: LEADFromJava.zip
NOTE: This functionality is EXPERIMENTAL and is not officially supported by LEADTOOLS.  This is more of a proof of concept and can help those who want this functionality.

This example was created using LEADTOOLS 14.5, Java 1.5 Update 9 with NETBEANS IDE, JNI (Java Native Interface), and Microsoft VC++ 6.0 and shows how to call the L_FileConvert function from Java.  You should already be familiar with programming in Java, C++, and the LEADTOOLS API.

Attached are all the necessary files for creating this project, any directories or files referenced are included in the attached .zip file..  The basic steps for calling a LEADTOOLS API function are:
1.) Write a simple Java class.  All that is necessary is a load of the DLL (made in step 7), a wrapper native function, and a main() to run and test the functions.  This java file is included in the zip file under the src\ directory.
2.) Create a C/C++ header file from the class created from step 1 using javah.exe and the -jni argument.  The full command would look like this: "javah -jni LEADFromJava"
3.) Create a new DLL project with (I used MFC AppWizard in MSVC6).  This is included in the C++ Part\ directory.
4.) Add the JNI header file (created from javah) to your C++ project.
5.) Include the JNI header file and any necessary LEADTOOLS header files.  Make sure your project settings have the proper Include and Library directories as well as any LEADTOOLS .lib files.
6.) Add the function(s) defined in the JNI header into the main header file and add types to the parameters.
7.) Build the DLL and place it into your System32 directory (or wherever your System.load() from Java is pointing to).
8.) Run your Java Application.

Here are some other good resources on using the JNI:
http://java.sun.com/j2se/1.4.2/docs/guide/jni/index.html
http://en.wikipedia.org/wiki/Java_Native_Interface

Greg Ross
LEADTOOLS Technical Support
   Report 
Post
LEAD Support Fo... » General » Example Request... » HOW TO: Call a LEADTOOLS API Function from Java

Powered by Community Server, by Telligent Systems