Article View: borland.public.jbuilder.java.language
Article #687Re: Calling a dll func from Java
From: Chris Lafferty
Date: Fri, 25 Feb 2005 20:41
Date: Fri, 25 Feb 2005 20:41
68 lines
3198 bytes
3198 bytes
Kevin,
I am having a similar problem. I have done what you suggested below, adding
the -Djava.library.path= to the location of the .DLL. It seems more like it
cannot find the function inside the DLL as opposed to the DLL itself as
before I copied the DLL to that location, the error described the DLL name
instead of the funciton. I wrote a test DLL and was able to call it from
Delphi, so I know the methods are public and exported properly. However,
when I run from java, I get the same error as yc did. Here is my code and
error:
public class DLLBridge
{
public DLLBridge() {
}
public native void RprtMain();
static{
System.loadLibrary("Reports");
}
public static void main(String[] args) {
DLLBridge dbridge = new DLLBridge();
dbridge.RprtMain();
}
}
java.lang.UnsatisfiedLinkError: RprtMain
at com.util.DLLBridge.RprtMain(Native Method)
at com.util.DLLBridge.main(DLLBridge.java:21)
Exception in thread "main"
Is there something I'm missing? Thanks in advance,
Chris
"Kevin Dean [TeamB]" <NkOdSePaAnM@datadevelopment.com> wrote in message
news:xn0dyx2iu419bb001-kdean@www.teamb.com...
> yc wrote:
>
> >
> > Hi,
> > I have a c dll (MyDll) stdcall fnc as follows.
> > stdcall int MyFnc(int FileNo, int IOType, unsigned char *
> > DataToWrite, unsigned char * DataRead);
> >
> > I try to call from java code, but it gives me an error as follows.
> >
> > Exception in thread "main" java.lang.UnsatisfiedLinkError: Myfunc
> > at X.MyFnc(Native Method)
> > at X.main(X.java:6)
> >
>
> That means that the Java process can't find the DLL in the system path.
> Make sure that you add the appropriate directory to the PATH statement
> or add -Djava.library.path=<dll_location> to the command line.
>
> --
> Kevin Dean [TeamB]
> Dolphin Data Development Ltd.
> http://www.datadevelopment.com/
>
> NEW WHITEPAPERS
> Team Development with JBuilder and Borland Enterprise Server
> Securing Borland Enterprise Server
> http://www.datadevelopment.com/papers/index.html
>
> Please see Borland's newsgroup guidelines at
> http://info.borland.com/newsgroups/guide.html
Technical Details
Message-ID:
<421f8461$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<421eedd1$2@newsgroups.borland.com> <xn0dyx2iu419bb001-kdean@www.teamb.com>Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,a69aa8c14ff32559 X-Google-Attributes: gidf74b3,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Chris Lafferty" <clafferty2001@yahoo.com> From: "Chris Lafferty" <clafferty2001@yahoo.com> Newsgroups: borland.public.jbuilder.java.language References: <421eedd1$2@newsgroups.borland.com> <xn0dyx2iu419bb001-kdean@www.teamb.com> Subject: Re: Calling a dll func from Java Date: Fri, 25 Feb 2005 15:41:10 -0500 Lines: 70 Organization: B2B Technologies, Inc. X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 216.64.94.24 Message-ID: <421f8461$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1109361761 216.64.94.24 (25 Feb 2005 12:02:41 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail