CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2000

    Using C++ Dll's from JAVA

    Hi there,

    Is it possible to use C++ dll's from within an applet, and if so how ???
    I was thinking about having a dll on my server performing tasks not possible to do directly from JAVA.

    Any reply appreciated

    Soren Staun Jorgensen

  2. #2

    Re: Using C++ Dll's from JAVA

    as far as i know we can call a script page from java so the script ill call internally the req. dll.
    for calling the script u use jsobject provided netscape..
    if u want further related info. feel to mail me at bharath@vsofti.stph.net

  3. #3
    Join Date
    Mar 2000
    Dublin, Ireland

    Re: Using C++ Dll's from JAVA

    To use C++ Dll's...
    Create a class:

    public class DllClass
    public native void showMessage(String text);

    The static part ensures that when this class is instanciated, the dll called "MyDll" is loaded straight away. (The dll must be in the same directory as your class files).
    The showMessage() part is a 'prototype' of the function within the loaded dll. In other words, "MyDll" should have a function called "showMessage()" that returns void and accepts a String.
    The native keyword tells Java that the method is defined in a dll loaded by the System.loadLibrary() method.
    Now, the biggest problem is that your dll must be written with the JNI library. If it isn't, then there might be problems. Look at the JNI documentation on this site.
    A class using the above class would then simply call the method:
    DllClass myDllClass = new DllClass();
    myDllClass.showMessage("Hello world");

    Mind you, there are all kinds of rules and restrictions with data types and type conversions when writing your dll.
    Hope this helps.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.