Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #15290 > unrolled thread
| Started by | clusardi2k@aol.com |
|---|---|
| First post | 2012-06-14 12:43 -0700 |
| Last post | 2012-06-14 13:20 -0700 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.java.programmer
Using JNI to Invoke C++ Method from Java via NetBeans 7.1.2 (Question: How to Import Stuff?) clusardi2k@aol.com - 2012-06-14 12:43 -0700
Re: Using JNI to Invoke C++ Method from Java via NetBeans 7.1.2 (Question: How to Import Stuff?) Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-14 12:52 -0700
Re: Using JNI to Invoke C++ Method from Java via NetBeans 7.1.2 (Question: How to Import Stuff?) clusardi2k@aol.com - 2012-06-14 13:20 -0700
| From | clusardi2k@aol.com |
|---|---|
| Date | 2012-06-14 12:43 -0700 |
| Subject | Using JNI to Invoke C++ Method from Java via NetBeans 7.1.2 (Question: How to Import Stuff?) |
| Message-ID | <5b852d14-dd46-463e-9d13-7602e17c151f@googlegroups.com> |
Hello,
I want to call a series of C++ routines from java using the Java Native Interface. 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 second part is the wrong part. The second part is my feeble attempt at changing 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++ class'. I was told to follow these steps. The steps that I followed to do this are.
Start NetBeans, highlight the name of the current project, right click on it, 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 were 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. This is what appears on the left of the IDE:
Libraries
MY_TEST - name_of_jar_file1.jar
META-INF
MANIFEST.MF
one.very.long.dotted.thing
MY_TEST - name_of_jar_file2.jar
META-INF
MANIFEST.MF
one.very.long.dotted.widget
Beans Binding - beansbinding-1.2.1.jar
JDK 1.7 (Default)
At this point, is it possible to just import one of the class' in the jar file, instantiate it, and then call the method desired. How would I go about doing this?
(Part 2)
0) FYI: There is only one class in this simple dot java program.
1) Without instantiating a class listed in one of the dot jar files, I put a call to a method (my_one_test) listed in one of the jar files (my_test does not exist anywhere else),
2) in the same dot java file, I created the following routine prototype for my_one_test:
"private native void my_one_test()", and
3) at the start of the class (in the dot java program), I added the lines:
static {
System.load ("C:\\User_name_0\\dist\\lib\name_of_jar_file1.jar");
System.load ("C:\\User_name_0\\dist\\lib\name_of_jar_file2.jar");
}
This compiles, but I get the following runtime error:
java.lang.UnsatisfiedLinkError: C:...\dist\lib\name_of_jar_file1.jar: Can't load this .dll (machine code=0x23) on a IA 32-bit platform
What do I do. Would creating a dot h file help.
Thanks,
First Time JNI user
[toc] | [next] | [standalone]
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Date | 2012-06-14 12:52 -0700 |
| Message-ID | <HhrCr.13739$qf3.2052@newsfe12.iad> |
| In reply to | #15290 |
On 6/14/12 12:43 PM, clusardi2k@aol.com wrote: The same thing multiple times. You're question has been seen. It is less likely to be responded to because you have spammed it multiple times to multiple newsgroups. Once was plenty.
[toc] | [prev] | [next] | [standalone]
| From | clusardi2k@aol.com |
|---|---|
| Date | 2012-06-14 13:20 -0700 |
| Message-ID | <3e5b3282-babb-40fb-a3a3-23d21917a95a@googlegroups.com> |
| In reply to | #15293 |
I figured it out! You put the packages mentioned (the dotted thing) with the dot jar files in the environment variable called CLASSPATH and the classes (from the jar) go in your import statements. For Windows, that looks like: set CLASSPATH=%CLASSPATH%;C:/.../dist/lib/file1.jar;C:/.../dist/lib/file2.jar import one.two.three.thing;//For the package (one.two.three.thing) listed on the IDE with the class called "thing". Thanks,
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web