

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
3 messages in net.java.dev.jna.usersRe: [jna-users] VB dll hellllllllllll...| From | Sent On | Attachments |
|---|---|---|
| java...@spamgourmet.com | Aug 29, 2007 2:44 pm | |
| Timothy Wall | Aug 29, 2007 3:39 pm | |
| java...@spamgourmet.com | Aug 30, 2007 6:35 pm |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] VB dll helllllllllllllllllllp | Actions... |
|---|---|---|
| From: | Timothy Wall (twal...@dev.java.net) | |
| Date: | Aug 29, 2007 3:39:19 pm | |
| List: | net.java.dev.jna.users | |
JNA allows you to access C functions exported from a DLL. Since you need to instantiate an object before accessing the function, it's not a C function. Even if you could get the object and its methods as function pointers, VB expects its arguments as a variant type, which JNA does not provide.
You might get some mileage from one of the Java COM bridges available (there are at least two on sourceforge); I don't know how far the .NET stuff is from COM.
On Aug 29, 2007, at 5:45 PM, java...@spamgourmet.com wrote:
BRIEF HISTORY: I am basically new to Java and most of what I know (vb and java) is self-taught I took a couple CSC Java classes in college about 5 years ago, and am currently doing the Head First Design Patterns book. I am starting a small application, so I decided now would be the perfect time to make the switch to Java I am mostly using jEdit, but turned to NetBeans for debugging help.
I mention all of that so that you know to dumb your responses down; I promise I won't be offended.
PROBLEM: I have to use a third-party DLL to fetch files from a repository (I did try to get them to give up the source code but no luck)
They gave me their DLL and a VB.net example: Private o as TheirDllNamespace.TheirClass = new TheirDllNamespace.TheirClass o.SignIn(user, pwd, repo) meaning SignIn is a method in TheirClass, and the full arch is: TheirDllNamespace.TheirClass.SignIn (String, String, String)
The DLL is strongly typed, and it is loaded in my GAC. I also put a copy in the project directory.
Initially I called: DllIface INSTANCE = (DllIface)Native.loadLibrary ("TheirDllNamespace", DllIface.class); That compiles but crashes at runtime saying: Unable to load library 'TheirDllNamespace' DllIface INSTANCE = (DllIface)Native.loadLibrary("c:/ TheirDllNamespace.dll", DllIface.class); So using the same call, I put the full path to the Dll and it now loads.
The error I get now is: Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot locate function 'SignIn'
MY GUESSES: 1. I have to figure out how to create and access an instance of TheirClass 2. Maybe their DLL doesn't satisfy this?: "This can be any library with exported functions, and it must be loadable from the JDK just like any native library. A good example is the local C library ( libc.so on linux or msvcrt.dll on windows)." 3. I have to figure out how to map to their funct?
Any help, suggestions, or other things to check are greatly appreciated!
_____________________________________________________
import com.sun.jna.*;
public interface DllIface extends Library { DllIface INSTANCE = (DllIface)Native.loadLibrary("c:/ TheirDllNamespace.dll", DllIface.class);
public boolean SignIn(String user, String pswd, String dbName); }
_____________________________________________________
public class DllInstance{
public boolean connect(String user, String pswd, String dbName){ try{ DllIface INSTANCE = DllIface.INSTANCE; INSTANCE.SignIn(user, pswd, dbName); return true; } catch(Exception ex){ return false; } } }
_______________________________________________________
public class DllMain { public static void main(String[] args) { DllInstance dll = new DllInstance(); dll.connect("guest", "", "TestRepo"); } }







