The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
August 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

C++ DLLs and Java Native Interface

Posted by Matt Gerrans on January 17, 2002 at 10:19 PM


> i have one dll written in c++, working fine, I want to make use of that dll from java, how to do that without changing anything in my c++ code...


I think you have two reasonable options:

First, if you absolutely don't want to touch your existing DLL, you can write a JNI-access module. Then you will have two DLLs, the one that implements the native side of the JNI stuff and simply interfaces to the original DLL and the original DLL itself.

The other option, if you don't mind updating the existing DLL to include the JNI stuff, is to do just that. Probably what you will do in this case, is create a new module with the JNI tools that matches the name of your existing DLL and add a method or two. Then, take all your old C++ code that was in the original DLL and add that to the new JNI DLL and you have both living together, with the new JNI methods simply calling appropriate existing functions and doing any necessary parameter transformations.

Neither of the options changes your existing C++ code.




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us