Using C++ Dll's from JAVA
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Using C++ Dll's from JAVA

  1. #1
    Join Date
    Apr 2000
    Location
    Denmark
    Posts
    17

    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
    CADeye

  2. #2
    Guest

    Re: Using C++ Dll's from JAVA

    hai,
    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
    regards
    bharath





  3. #3
    Join Date
    Mar 2000
    Location
    Dublin, Ireland
    Posts
    124

    Re: Using C++ Dll's from JAVA

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

    public class DllClass
    {
    public native void showMessage(String text);
    static
    {
    System.loadLibrary("MyDll");
    }
    }


    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.

    Regards,
    dogBear





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

This is a CodeGuru survey question.


Featured


HTML5 Development Center