This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Info on JNI and accessing dll methods.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trying to get started here, looking for direction... or maybe confirm that I am looking the right way. :-)
I am just trying to explore a possible solution to a problem I have by using JNI. I need to call a method in a C++ dll, and I think/believe JNI might be what I need to use.
However, the dll is supplied by a vendor (MS SQL Server DMO) and is not likely to have a JNI.h header file included. If all I want is to call methods in the dll, and receive return values back, does the C++ program need to be modified to work with JNI? I have read that you need to compile the C++ code with a JNI.h header file, but am unsure if this is only if I want to be able to call or invoke Java methods from the C++ program.
The short of it is, I want to be able to list the visible SQL Servers on a network and connect to the one the user chooses. I know the SQL Server DMO C++ library provides this functionality.
I have not used JNI before, but if it works, I can learn. :-)
Which leads to one more question: any good books or places to start on this? Nothing too fancy to start, and just to say, I do know about the Java Tutorial... which is why I have this question. :-)
Any suggestions would be appreciated,
BillR
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The usual way to accomplish this is not to call the DLL directly from Java, but to write a very small C or C++ program which provides a JNI-accessible function which in turn calls the DLL. You call your "wrapper" function from Java using JNI, and use it to return the results you need.
 
author
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a nice Step-by-Step tutorial.
http://java.sun.com/docs/books/tutorial/native1.1/stepbystep/step1.html
It doesn't get into return values but it's a stright forward primer.
Sean
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Please check out this page where http://www.geocities.com/sahirshah/JNI1.html
I have posted step by step instructions on how to integrate a
piece of legacy VB code with a java application. The same thing
can be applied for C++ dlls by skipping a few of the steps.
Rgds
Sahir
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Sahir Shah:

Please check out this page where http://www.geocities.com/sahirshah/JNI1.html
I have posted step by step instructions on how to integrate a
piece of legacy VB code with a java application. The same thing
can be applied for C++ dlls by skipping a few of the steps.
Rgds
Sahir



Hi Sahir,
I was trying to get some information regarding how to integrate VB with JNI. But the link which u have given is giving a message " the page not found". Hence can u mail me the site address where uve posted it. The steps about the same would be very helpful.
Thank you very much,
Regards
Shilpa
Sorry for the above.Ive now found the steps u have posted. But the url is
"http://www.geocities.com/sahirshah/javapapers/jni.html".
Hi,
I went thru the steps given by you. But ive got stuck at the last step, that is while giving the implementation of Test.h file. When i compile the file it throws the foll error:
"unexpected end of file while looking for the header directive"
Should i include this implementation in the VBToJava project or should it be kept seperate? Can u please elaborate the last steps again.
Thankyou.
[This message has been edited by shilpa (edited July 30, 2001).]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sahir,
This is Kartik from IIM-Ahmedabad. We are working on a multi-language Web Portal for GrassRoot Innovations. We are working with JSP/XML/SQL. My problem is to call the external DLL from the JSP file. I don't know how should i proceed , i understood the steps given at listed site but it is not much helpful foor my case.
I am stuck up at this point so...
Your help will be a great support
Thanks and Regards
Kartik Shah

Originally posted by Sahir Shah:

Please check out this page where http://www.geocities.com/sahirshah/JNI1.html
I have posted step by step instructions on how to integrate a
piece of legacy VB code with a java application. The same thing
can be applied for C++ dlls by skipping a few of the steps.
Rgds
Sahir



------------------
Kartik Shah
WebMaster/Database Administrator
KnowNet-Grin, Indian Institute of Management,
Ahmedabad - 380015, Gujarat, India.
Ph. +91 79 6324713
Direct +91 79 6307857
Fax: +91 79 6307341
 
Can't .... do .... plaid .... So I did this tiny ad instead:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!