Article View: borland.public.jbuilder.java.language
Article #17406UnsatisfiedLinkError when Java calling into C++ DLL via JNI
From: George C. Hetrick
Date: Tue, 17 Nov 1998 00:00
Date: Tue, 17 Nov 1998 00:00
101 lines
4076 bytes
4076 bytes
I'm trying to use JNI to call into a DLL I've written.
I appear to be able to correctly put the DLL in my path, so that it is
seen, but I don't manage to connect up with the routine in the
DLL. I'm attaching the Java declaration for the native interface, the
C++ declaration (I've tried it both with and without the EXTERN_C, to
see if that made a difference), and run-time output showing the error.
I know I'm doing something silly, but what? Does the fact that the
error says "java.lang.UnsatisfiedLinkError: initializeEngine" mean
it's really looking for an entry point named 'initializeEngine',
rather than "Java_OMTool_scripting_PerlScriptingEngine_initializeEngine",
which is what javah generates?
----------------
//PerlScriptingEngine engine =
(PerlScriptingEngine)ScriptingEngine.newScriptingEngine("omtool.scripting.Pe
rlScriptingEngine");
ScriptingEngine engine =
ScriptingEngine.newScriptingEngine("omtool.scripting.PerlScriptingEngine");
engine.initializeEngine();
----------------
package omtool.scripting;
public class PerlScriptingEngine extends ScriptingEngine {
public PerlScriptingEngine() {
System.out.println("Engine created!");
}
public native void initializeEngine();
public native void shutdownEngine();
public native void executeScript(String script);
}
----------------
EXTERN_C JNIEXPORT void JNICALL
Java_OMTool_scripting_PerlScriptingEngine_initializeEngine
(JNIEnv *curEnv, jobject curObj) {
----------------
First, show error if DLL not in path
>C:\Personal\Java\omtool>java omtool.Application
>java.lang.UnsatisfiedLinkError: no PerlScriptingEngine in java.library.path
> at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1133)
> at java.lang.Runtime.loadLibrary0(Runtime.java:463)
> at java.lang.System.loadLibrary(System.java:745)
> at omtool.Application.<clinit>(Application.java:8)
>Exception in thread "main"
>C:\Personal\Java\omtool>set
path=c:\personal\C++_Projects\OMTool_Perl_Scripting_Engine\PerlScriptingEngi
ne\;%path%
Now, DLL is in path, but entry is not found -- note that it is asking
for simply 'initializeEngine'
>C:\Personal\Java\omtool>java omtool.Application
>java omtool.Application
>Engine created!
>java.lang.UnsatisfiedLinkError: initializeEngine
> at omtool.Application.main(Application.java:13)
>Exception in thread "main"
>C:\Personal\Java\omtool>DUMPBIN
C:\PERSONAL\C++_Projects\OMTool_Perl_Scripting_Engine\PerlScriptingEngine\PE
RLSCRIPTINGENGINE.DLL /EXPORTS
>Microsoft (R) COFF Binary File Dumper Version 6.00.8168
>Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
>
>
>Dump of file
C:\PERSONAL\C++_Projects\OMTool_Perl_Scripting_Engine\PerlScriptingEngine\PE
RLSCRIPTINGENGINE.DLL
>
>File Type: DLL
>
> Section contains the following exports for PerlScriptingEngine.dll
>
> 0 characteristics
> 36522E8F time date stamp Tue Nov 17 21:18:55 1998
> 0.00 version
> 1 ordinal base
> 3 number of functions
> 3 number of names
>
> ordinal hint RVA name
>
> 1 0 000029D0
_Java_OMTool_scripting_PerlScriptingEngine_executeScript@12
Dump shows that full name is
_Java_OMTool_scripting_PerlScriptingEngine_initializeEngine
> 2 1 00002910
_Java_OMTool_scripting_PerlScriptingEngine_initializeEngine@8
> 3 2 00002950
_Java_OMTool_scripting_PerlScriptingEngine_shutdownEngine@8
>
> Summary
>
> 1000 .data
> 2000 .rdata
> 1000 .reloc
> 7000 .text
Technical Details
Message-ID:
<72tctb$2s31@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,c7294822695a5061,start X-Google-Attributes: gidf74b3,public From: "George C. Hetrick" <hetrick@acm.org> Subject: UnsatisfiedLinkError when Java calling into C++ DLL via JNI Date: 1998/11/17 Message-ID: <72tctb$2s31@forums.borland.com> X-Deja-AN: 413001782 Organization: Another Netscape Collabra Server User X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Newsgroups: borland.public.jbuilder.java.language