Article View: borland.public.jbuilder.java.api
Article #2290Re: JNI Link Error
From: Conor Boyd
Date: Mon, 19 Mar 2001 12:14
Date: Mon, 19 Mar 2001 12:14
74 lines
2463 bytes
2463 bytes
Paul,
Even though your native method is called MyMax, the JVM will look for a DLL
method with a slightly different signature; something along the lines of
java_nativetestpackage_nativetestclass_MyMax(...) - I can't remember the
exact syntax.
Run javah on your Java class, and view the (C++) header file produced to get
an idea of what I'm talking about. You'll have to try and translate that
signature into a similar Delphi one.
There is some Delphi JNI at the Project JEDI site (www.delphi-jedi.org)
under Cross-platform API libraries, which you should find helpful.
HTH,
Conor
"Paul Loht" <ploht@promisant.com> wrote in message news:3ab38e3f_1@dnews...
> I am trying to load a dll written with Delphi from a java program, and I
am
> getting the error:
>
> java.lang.UnsatisfiedLinkError: MyMax
>
> I can't seem to spot the problem. Here is the code for the java program
and
> the dll, can anyone see the problem?
>
> package NativeTestPackage;
>
> public class NativeMaxClass {
>
> public static native int MyMax(int x, int y);
>
> static
> {
> System.loadLibrary("NativeMax");
> }
>
> public NativeMaxClass()
> {
> }
>
> public static void main(String[] args)
> {
> int i, j, k;
> j = 13;
> k = 2;
> i = MyMax(j, k);
> }
> }
>
>
> library NativeMax;
>
> uses
> SysUtils;
>
> function MyMax(x, y: Integer): Integer; stdcall;
> begin
> if X > Y then
> Result := X
> else Result := Y;
> end;
>
> exports
> MyMax;
>
> begin
> end.
>
>
>
Technical Details
Message-ID:
<3ab5f8eb$1_2@dnews>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!128.230.129.106!news.maxwell.syr.edu!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews!62.189.65.129References:
<3ab38e3f_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,6c42ea9d61f8e960 X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2001-03-23 03:25:21 PST From: "Conor Boyd" <conor.nospam@nospam.zonal.co.uk> Newsgroups: borland.public.jbuilder.java.api References: <3ab38e3f_1@dnews> Subject: Re: JNI Link Error Date: Mon, 19 Mar 2001 12:14:29 -0000 Lines: 76 Organization: Zonal Retail Data Systems X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 NNTP-Posting-Host: 62.189.65.129 Message-ID: <3ab5f8eb$1_2@dnews> X-Trace: 19 Mar 2001 04:17:47 -0800, 62.189.65.129 Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!128.230.129.106!news.maxwell.syr.edu!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews!62.189.65.129