Using JNI to Call C++ Methods from Java Using NetBeans IDE 7.1.2

  • Follow


Hello,

I want to call a series of C++ routines from java using the Java Native Int=
erface. The IDE that I'm using is NetBeans 7.1.2.

Below is a two part description. The first part is background. It explains =
how I was told to setup two jar files that refer to my C++ routines. The se=
cond part is the wrong part. The second part is my feeble attempt at changi=
ng my code so that it invokes a routine in the C/C++ library.

(Part 1)
I setup NetBeans to use 2 dot jar files to refer to my C++ routines. I was =
told to follow these steps. The steps that I followed to do this are.=20

Start NetBeans, highlight the name of the current project, right click on i=
t, select Add Library, select Create..., name the library MY_TEST, click ok=
, press the "Add JAR/Folder..." button, and select the two jar files that w=
ere given to me.

The 2 jar files now appear on the left side of the IDE under MY_TEST. Below=
 that is a description of each method in the file.

(Part 2)
0) FYI: There is only one class in this simple dot java program.=20
1) I put a call to a method (my_test) listed in one of the jar files (my_te=
st does not exist anywhere else),
2) in the same dot java file, I created the following routine prototype for=
 my_test:

 "private native void my_test()", and=20

3) at the start of the class (in the dot java program), I added the lines:

    static {
      System.load ("C:\\User_name_0\\dist\\name_of_jar_file1.jar");
      System.load ("C:\\User_name_0\\dist\\name_of_jar_file2.jar");
    }=20

This compiles, but I get the following runtime error:

java.lang.UnsatisfiedLinkError: C:...\dist\lib\JavaApiClient.jar: Can't loa=
d this .dll (machine code=3D0x23) on a IA 32-bit platform

What do I do. Would creating a dot h file help.

Thanks,
First Time JNI user
0
Reply clusardi2k (487) 6/14/2012 7:17:14 PM


0 Replies
39 Views

(page loaded in 0.228 seconds)


Reply: