🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Call a DLL from a java application ...

#16170
From: Jason Burton
Date: Tue, 23 Mar 1999 00:00
32 lines
1802 bytes
>I use the the method System.LoadLibrary("xxx") where xxx is the name of the
>dll. The function that I want to call is declared public native in the java
>file.
>At runtime, I have the following exception : java.lang.UnsatisfiedLinkError
>: yyy where yyy is the function that I call.
>
>Can you help me to fix this ? Do you know examples of DLL call from java
>application ?


When you declare a native function, such as:

package MyPackage;
...
public native void myFunc();

the C header file would have the function Java_MyPackage_myFunc.  JNI calls
use this naming convention, meaning that if the DLL has a function called
myFunc, you can't call it directly - the DLL must have a function called
Java_MyPackage_myFunc.
The way around this that I have used is to create a second DLL as a wrapper
for the original.  I doubt there is any way to create a DLL from within
Java - I use C++ or Delphi.  The additional DLL would use the JNI naming
conventions (Java_MyPackage_myFunc), and would do all necessary type
conversions (these are a total pain), and then call the original DLL using
the real naming (myFunc).
If anybody knows of a better way to do this, PLEASE LET ME KNOW!!!  This is
cumbersome at best, but it works.


Hope this helps,
Jason
Technical Details
Message-ID: <7d8jmb$lao25@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7d8dnf$l4t20@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,5ea51dfa91fb275
X-Google-Attributes: gidf74b3,public
From: "Jason Burton" <Jason.Burton@McLeodSoftware.com>
Subject: Re: Call a DLL from a java application ...
Date: 1999/03/23
Message-ID: <7d8jmb$lao25@forums.borland.com>
X-Deja-AN: 458045249
References: <7d8dnf$l4t20@forums.borland.com>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.language