Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

JNI Woes

Thread view: 
ShadowPhoenix - 30 Oct 2006 15:00 GMT
I've looked extensively on Google for JNI tutorials and documentation,
but I can't seem to figure this out;  I can't be the first one to have
wanted to do this, or maybe I am just misunderstanding the way JNI
works.

I have a dll from another company.  It is a total black box and I do
not have access to the source code at all.  I have great documentation
on the API functions themselves so that is not a problem.

I am trying to call functions on the dll from Java, but all the things
I have read include running javah on the class file (which I can
successfully do), but it doesn't seem to help because I don't have
access to the source code, so I can't really use the header file.

Writing a wrapper library to implement the functions from the dll to
specifically work with Java (including jni.h, etc) is not at all
feasible because there are hundreds and hundreds of functions, and I
don't have enough time to write a library for them all.

Any help anyone can give would be most appreciated!
Gordon Beaton - 30 Oct 2006 15:27 GMT
> I am trying to call functions on the dll from Java, but all the things
> I have read include running javah on the class file (which I can
[quoted text clipped - 5 lines]
> feasible because there are hundreds and hundreds of functions, and I
> don't have enough time to write a library for them all.

Unfortunately for you, the technical reality of things doesn't care
how much time you've got, and Java does not offer any other technical
solutions. You can't invoke arbitrary C functions from a Java
application. The library must have been written to be used from Java,
wrapped suitably, or moved to a separate process that you communicate
with using other mechanisms.

Consider that using JNI doesn't necessarily mean that you need to wrap
your functions on a 1:1 basis. Choose a suitable place for your JNI
boundary, e.g. by moving it to a higher abstraction level you might
get a smaller contact area.

Or perhaps you don't really need all of those hundreds and hundreds of
functions. You only need to write wrappers for the stuff actually used
by your application.

There might also be some commercial products that can automate the
wrapping.

/gordon

Signature

[ don't email me support questions or followups ]
g o r d o n  +  n e w s  @  b a l d e r 1 3 . s e

Bill Medland - 30 Oct 2006 18:04 GMT
>> I am trying to call functions on the dll from Java, but all the things
>> I have read include running javah on the class file (which I can
[quoted text clipped - 24 lines]
> There might also be some commercial products that can automate the
> wrapping.

http://www.excelsior-usa.com/xfunction.html

might suite the OP's needs.

> /gordon

Signature

Bill Medland



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.