🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #690

Re: Calling a dll func from Java

#690
From: Chris Lafferty
Date: Sun, 27 Feb 2005 04:31
71 lines
3938 bytes
Kevin/Alexey,

Thanks for the quick reply. He cleared up the basic issue of calling a dll
directly. First of all, I need to do some more reading up on JNI, I'm
obviously a little confused...but I guess what I am confused about is 1) is
the JNI C layer just an interface from Java to the DLL (when I ran javah, it
created a function called Java_DLLBridge_RprtMain which I'm hoping is just a
conduit from java to the DLL) or is 2) it actually asking for me to rewrite
a function that already works in a DLL but with parameters that Java can
communicate with. I'm guessing it's the 1st one, because it seems the second
alternative would defeat the whole purpose of using a fully
functioning/tested dll. Anyway, thanks for the info.

Chris

"Kevin Dean [TeamB]" <NkOdSePaAnM@datadevelopment.com> wrote in message
news:xn0dyxhy5p2f42000-kdean@www.teamb.com...
> Chris Lafferty wrote:
>
> > 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
>
> The post from Alexey is likely to be more correct than the one I have
> given you.  I'm not intimately familiar with JNI and so gave the answer
> that solves about 90% of the JNI questions we get.  Have you done what
> Alexey suggests?
>
> -- 
> 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: <42214418$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!meganewsservers.com!feeder2.on.meganewsservers.com!feed.cgocable.net!pd7cy1no!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <421eedd1$2@newsgroups.borland.com> <xn0dyx2iu419bb001-kdean@www.teamb.com> <421f8461$1@newsgroups.borland.com> <xn0dyxhy5p2f42000-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> <421f8461$1@newsgroups.borland.com> <xn0dyxhy5p2f42000-kdean@www.teamb.com>
Subject: Re: Calling a dll func from Java
Date: Sat, 26 Feb 2005 23:31:25 -0500
Lines: 73
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: 68.210.190.173
Message-ID: <42214418$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1109476376 68.210.190.173 (26 Feb 2005 19:52:56 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!meganewsservers.com!feeder2.on.meganewsservers.com!feed.cgocable.net!pd7cy1no!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail