Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Need some advices regarding JNI

Reply
Thread Tools

Need some advices regarding JNI

 
 
JPractitioner
Guest
Posts: n/a
 
      07-24-2006
Hi all!

I already have a .dll file. I want to call a few functions from the
..dll file. I have a pdf documentation that shows me the function specs
of the dll file (i.e. function name, function call, function return,
etc). Apparently those are C/C++ code.

I figured out that this can be done with JNI. However it seems that,
with JNI, I will be creating another .dll

(I refer to this tutorial and done with it:
http://www.iut-info.univ-lille1.fr/d...1.1/index.html)

So my question is, do i have to create another .dll which will be used
to call the other .dll that need to use?

I wonder if, i can call the dll functions directly from java code. i.e.
after
System.load(theDll.dll);
//call the functions here

If this cannot be done, that means i will have to call the functions
from a c code that will implement java header files right?

Your point of views are very much appreciated.

Thank you.

 
Reply With Quote
 
 
 
 
Tim Ward
Guest
Posts: n/a
 
      07-24-2006
"JPractitioner" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>
> So my question is, do i have to create another .dll which will be used
> to call the other .dll that need to use?


Yes. JNI has a particular view of the world, and insists on only making DLL
calls that conform to this view of the world. Unlike when programming in VB,
you can't make a call to an arbitrary DLL function from Java.

If you already have a DLL which has not been written to be called by JNI,
and you don't have the source code to that DLL so can't modify it, then yes,
you have to write your own DLL to sit as a glue layer between the Java code
and the existing DLL.

--
Tim Ward
Brett Ward Limited - www.brettward.co.uk


 
Reply With Quote
 
 
 
 
JPractitioner
Guest
Posts: n/a
 
      07-24-2006
Thanks a lot Tim Ward, for your reply.
Yup, I cant modify the source code of the DLL.
This means i have to learn C. I am so "happy".

Thanks again Tim.

Tim Ward wrote:
> If you already have a DLL which has not been written to be called by JNI,
> and you don't have the source code to that DLL so can't modify it,..


 
Reply With Quote
 
Jean-Francois Briere
Guest
Posts: n/a
 
      07-24-2006
If you don't want to write JNI code there is a way.
You could use a third party tool that does the hard work for you.

Have a look at JNative:
http://sourceforge.net/project/showf...roup_id=156421

This library allows developpers to access native libraries (DLL and
lib.so) from java. You do NOT need to compile a line of C/C++ to use
it.

Regards

 
Reply With Quote
 
JPractitioner
Guest
Posts: n/a
 
      07-25-2006
Hi Jean-Francois Briere,
The JNative that u suggested really helps.
Thanks a lot!

Jean-Francois Briere wrote:
> Have a look at JNative:
> http://sourceforge.net/project/showf...roup_id=156421


 
Reply With Quote
 
JPractitioner
Guest
Posts: n/a
 
      07-25-2006
Jean Francois, obviously I have one problem using JNative. Do u know
how i can send parameters with byte[] as its data type?
It seems like JNative only support String (Type.String), int
(Type.INT), long (Type.LONG), struct (Type.STRUCT) and void
(Type.VOID).

I am still finding the solutions, and I already asked in JNative news.
Please help me if u know the way before i do.

Many Thanks.

Jean-Francois Briere wrote:
> If you don't want to write JNI code there is a way.
> You could use a third party tool that does the hard work for you.
>
> Have a look at JNative:
> http://sourceforge.net/project/showf...roup_id=156421
>
> This library allows developpers to access native libraries (DLL and
> lib.so) from java. You do NOT need to compile a line of C/C++ to use
> it.
>
> Regards


 
Reply With Quote
 
JPractitioner
Guest
Posts: n/a
 
      07-25-2006
I ve got the way already by doing something like this..
byte[] b = new buffer[256];
by using object.setParameter(1, Type.INT,buffer);

However now, i got the following errors..

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x1000147f, pid=4360,
tid=4468
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode,
sharing)
# Problematic frame:
# C [BridgeMini.dll+0x147f]
#
# An error report file with more information is saved as
hs_err_pid4360.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#

Hmmm.....
hope some one has any idea of what i can learn from this error

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need advices regarding the strings (str, unicode, coding) used asinterface for an external library. jmfauth Python 2 11-23-2010 02:02 PM
I wanna some advices about 642-901 BSCI Casper2004 Cisco 1 08-31-2007 10:06 PM
some kind of detector, need advices... Joh Python 2 07-15-2004 09:49 PM
Forms autentication and registration page - some advices NWx ASP .Net Security 1 02-13-2004 06:23 AM
Forms autentication and registration page - some advices NWx ASP .Net 1 02-13-2004 06:23 AM



Advertisments