Results 1 to 1 of 1
  1. #1
    hura is offline Member
    Join Date
    Dec 2010
    Posts
    5
    Rep Power
    0

    Default How can java call virtual method from C++?

    Hi guys,

    I have a C++ dll file, a C++ header file including all methods that I can use. But the methods from the header file are virtual, then how can I use it. I've tried many way, but unable to call virtual methods from my java program.

    My header file is like this:
    Java Code:
    class CManagerInterface
      {
    public:
       virtual int  __stdcall Connect(LPCSTR server)          =0;
       virtual int  __stdcall Disconnect()                          =0;
       virtual int  __stdcall IsConnected()                        =0;
    }

    I use a tool named dllexp to view which methods the dll contains and I see that it doesn't contain any methods in the header file.

    if I write my program in C++, I'd do something like this:
    Java Code:
    class CManager
      {
       ........
       loadDLLfile();
       CManagerInterface *manager;
       CManagerInterface* operator->() { return(manager);       }
      };
    
    int main(){
      manager-Connect("myserver");
    }
    Everything works fine as I expected.
    Now I wanna use the methods from the header file in my java program but I've found the way to do that.
    I can load dll file, but then it says that it can't find the method.

    What should I do?
    Thx in advance.
    Last edited by hura; 12-24-2010 at 07:55 AM.

Similar Threads

  1. call a JSP method
    By sauravsinha in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 09-26-2011, 04:19 PM
  2. Call Java Method in MS SQL
    By mexyz in forum New To Java
    Replies: 19
    Last Post: 02-17-2010, 01:38 PM
  3. Call java method from jsp
    By saiphani723 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 02-25-2009, 11:21 AM
  4. Call Java Method
    By hussainzim in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 05-15-2008, 07:22 AM
  5. cannot call private method from static method
    By jon80 in forum New To Java
    Replies: 3
    Last Post: 05-07-2008, 08:37 AM

Posting Permissions

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