Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #15303 > unrolled thread
| Started by | clusardi2k@aol.com |
|---|---|
| First post | 2012-06-15 08:22 -0700 |
| Last post | 2012-06-18 02:27 -0700 |
| Articles | 6 — 2 participants |
Back to article view | Back to comp.lang.java.programmer
Using JNI Produced Jar Files: java.lang.UnsatisfiedLinkError clusardi2k@aol.com - 2012-06-15 08:22 -0700
Re: Using JNI Produced Jar Files: java.lang.UnsatisfiedLinkError clusardi2k@aol.com - 2012-06-16 22:47 -0700
Re: Using JNI Produced Jar Files: java.lang.UnsatisfiedLinkError Roedy Green <see_website@mindprod.com.invalid> - 2012-06-16 23:02 -0700
Re: Using JNI Produced Jar Files: java.lang.UnsatisfiedLinkError clusardi2k@aol.com - 2012-06-16 23:16 -0700
Re: Using JNI Produced Jar Files: java.lang.UnsatisfiedLinkError clusardi2k@aol.com - 2012-06-16 23:46 -0700
Re: Using JNI Produced Jar Files: java.lang.UnsatisfiedLinkError Roedy Green <see_website@mindprod.com.invalid> - 2012-06-18 02:27 -0700
| From | clusardi2k@aol.com |
|---|---|
| Date | 2012-06-15 08:22 -0700 |
| Subject | Using JNI Produced Jar Files: java.lang.UnsatisfiedLinkError |
| Message-ID | <c8c37ba8-17af-4b59-b814-cdf840f33b18@googlegroups.com> |
On Windows 7, I am trying to use the JNI (Java Native Interface) to invoke a C++ method from java NetBeans 7.1.2 (Java SE Development Kit 7u4 x86 32-bit).
Background: I was given two dot jar files (produced using the NetBeans JNI process) to use in a project. The filenames of these two JNI produced files begin with "java".
My simple project consists of another dot java file. I'm, basically, just converting a working C++ project to a java project.
Below, I first import the JNI C++ class described via the associated jar file(s). The import information came from the JavaBeans "Projects" window listing above all the available JNI class names.
import com.one.two.three.My_Class;
//import com.six.seven.eight.*;
Second, in a java program constructor, I invoke the following static method:
My_Class.a_first_test();
(I know the above method is static because the similar C++ program runs perfectly.)
Problem Description: This java project compiles. But when I run the program, I receive the below error message.
run:
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: com.one.two.three.four.five_init()V
at com.one.two.three.four.five_init(Native Method)
at com.one.two.three.four.<clinit>(four.java:4746)
at com.one.two.three.My_Class.a_first_test(My_Class.java:51)
at My_Prj.<init>(My_Project.java:28)
at My_Prj$11.run(My_Project.java:585)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:701)
at java.awt.EventQueue.access$000(EventQueue.java:102)
at java.awt.EventQueue$3.run(EventQueue.java:662)
at java.awt.EventQueue$3.run(EventQueue.java:660)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:671)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
My employeer told me I should not make public identifier names etc, so (above) I have carefully renamed code identifiers.
------
Here are the steps that I followed to try to fix the problem. These steps did not work!
(0) FYI: The contents of the jar files match (viewed via command jar tf jar-file) what is displayed by NetBeans.
(1) To gather information, I put the following line of code as the first line in the constructor:
System.out.println(System.getProperty("java.library.path"));
I ran this program. The line of code gave me paths to folders such as:
C:\Program Files\Java\jdk1.7.0_04\bin;
C:\Windows\Sun\Java\bin;
C:\Windows\system32;
C:\Windows;
C:\Program Files\QuickTime\QTSystem\;
C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;
C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;
C:\Program Files\Microsoft SQL Server\90\Tools\binn\;.
(2) Since there was also a beansbinding-1.2.1.jar (and associated dot dll file) file in my project, I looked for two dot dll files that correspond to the two dot jar files given to me. I found none that had "java" pre-appended to the filenames, but I found two without "java" pre-appended to the filenames. So, I just copied and renamed the two files that I found and put them in one of the folders produced from step 1.
(3) Because of the beansbinding-1.2.1.jar file in my project, I copied my two dot jar files to the same folder. I did not rename any of the dot jar files.
(4) I compiled and ran the project in NetBeans, but I received the exact same error message.
------
Some References:
Error message:
http://stackoverflow.com/questions/10029555/exception-in-thread-awt-eventqueue-0-java-lang-unsatisfiedlinkerror-no-jnotif
Setting environment variable CLASSPATH required:
http://www.webdeveloper.com/forum/archive/index.php/t-60643.html
Thank you,
[toc] | [next] | [standalone]
| From | clusardi2k@aol.com |
|---|---|
| Date | 2012-06-16 22:47 -0700 |
| Message-ID | <2c606a27-7189-4d99-b45c-f17995529c8f@googlegroups.com> |
| In reply to | #15303 |
The following link contains a book describing a similar runtime error to mine. The book says I am missing a "DLL" (Dynamic Link Library)! http://java.sun.com/docs/books/jni/ So, I have to try and determine where/how to get/build a DLL! Anybody have any ideas? My own large set of C++ routines has a dot jar file which allows me to compile and link my java project together. (I import the classes after adding the jar to the project.) Question: Can I create (with NetBeans) a DLL from my dot jar file, any suggestions. Referenced Book: The Java Native Interface Programmer’s Guide and Specification by Sheng Liang (published 1999) On Page 31 of the pdf: java.lang.UnsatisfiedLinkError: no HelloWorld in library path at java.lang.Runtime.loadLibrary(Runtime.java) at java.lang.System.loadLibrary(System.java) at HelloWorld.main(HelloWorld.java) Thanks for any help,
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-06-16 23:02 -0700 |
| Message-ID | <vjsqt7lidudvip8i3sm9claeccagvr2ot4@4ax.com> |
| In reply to | #15303 |
By far the easiest way to implement JNI is with Java Web Start. It automatically selects the right DLL and it also installs it for you where load/loadlibrary can find it. http://mindprod.com/jgloss/jni.html http://mindprod.com/jgloss/javawebstart.html -- Roedy Green Canadian Mind Products http://mindprod.com Controlling complexity is the essence of computer programming. ~ Brian W. Kernighan 1942-01-01 .
[toc] | [prev] | [next] | [standalone]
| From | clusardi2k@aol.com |
|---|---|
| Date | 2012-06-16 23:16 -0700 |
| Message-ID | <e8fe89fd-3767-44ea-8bfc-6a9228b890e4@googlegroups.com> |
| In reply to | #15353 |
On Sunday, June 17, 2012 2:02:00 AM UTC-4, Roedy Green wrote: > By far the easiest way to implement JNI is with Java Web Start. It > automatically selects the right DLL and it also installs it for you > where load/loadlibrary can find it. > > http://mindprod.com/jgloss/jni.html > http://mindprod.com/jgloss/javawebstart.html > -- > Roedy Green Canadian Mind Products My requirements are to use NetBeans and a dot jar file. Thanks but still looking,
[toc] | [prev] | [next] | [standalone]
| From | clusardi2k@aol.com |
|---|---|
| Date | 2012-06-16 23:46 -0700 |
| Message-ID | <ebdaa001-71fc-4f90-99a6-8bd23e49088f@googlegroups.com> |
| In reply to | #15354 |
One alternative to using the dot jar file would be to throw the dot jar away, Thus, I could build a C++ class (in NetBeans per JNI) that uses a small subset of the class' mentioned in the large dot jar file, and just use JNI to communicate with a java NetBeans project! A second alternative would be to also not use the dot jar file, build a C++ class (maybe in NetBeans or Visual Studio) that uses a small subset of the class' mentioned in the dot jar file, have the C++ program write all the required data to a file, and use a java NetBeans project to read from the new file after first invoking the corresponding C++ project!
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-06-18 02:27 -0700 |
| Message-ID | <h0ttt7da0kd5ks4f432j8cc3ojm3ketuqb@4ax.com> |
| In reply to | #15354 |
On Sat, 16 Jun 2012 23:16:46 -0700 (PDT), clusardi2k@aol.com wrote, quoted or indirectly quoted someone who said : >My requirements are to use NetBeans and a dot jar file. You can can use NetBeans to develop JWS, and JWS is implemented with an ordinary .jar file. You may imagine that JWS is something other than Java. It is just an ordinary java jar plus a *.jnlp file. There are some JWS classes you can use to write an installer, but you don't have to use any of them. -- Roedy Green Canadian Mind Products http://mindprod.com If you look in a computer programmer's freezer you will find all kinds of containers, but none of them labeled. They do the same thing creating files without labeling the encoding. You are just supposed to know. Ditto with the MIME type, the separator and comment delimiters and column names in CSV files. Ditto with the endian convention. Imagine how much more civilised life would have been if Martha Stewart were the first programmer.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web