CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588

    Arrow How to integrate Java programs with other programs in other languages ?

    Hi,

    We are trying to develop a simple Code War program that will allow client programs in different programming languages to compete with each other. We would like to support Java as well as C++, VB and C#. As my knowledge of Java is pretty limited, I'd like to ask you which method would work best (work at all ?) for communicating. The server will be written in C++, but that shouldn't matter.

    The options I have come up with so far are:
    DLL-based approach with exported functions. As far as I understand Java, it's impossible to do this, right ?
    COM-based approach. I would guess that Java could use COM on Windows platforms, but I might be wrong.
    TCP/IP. This is the only other option that I could come up with. I know it would work in Java, but would be a real pain in the other programming languages.

    I'm thankful for any suggestions and ideas. If you would like to help in coding, just visit the forum Code War
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

  2. #2
    Join Date
    Jan 2002
    Location
    Halifax, NS, Canada
    Posts
    985
    DLL-based approach with exported functions. As far as I understand Java, it's impossible to do this, right ?
    You can use DLL's with Java via the JNI (Java Native Interface). Basically you include JNI.h in your C/C++ DLL and there you go. There is a little more to it, but yes it is possible.

    COM-based approach. I would guess that Java could use COM on Windows platforms, but I might be wrong.
    Not sure on this one. Maybe dlorde might be a little more help here.

    TCP/IP. This is the only other option that I could come up with. I know it would work in Java, but would be a real pain in the other programming languages.
    I've never actually used the JNI approach before, but I have used TCP/IP to communicate with Java and VB.

  3. #3
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588
    Originally posted by Goodz13
    You can use DLL's with Java via the JNI (Java Native Interface). Basically you include JNI.h in your C/C++ DLL and there you go. There is a little more to it, but yes it is possible.
    What I want is to call Java functions from C++, and C++ functions from Java. So this is possible with a simple DLL approach ?

    Actually the COM thing is better, since VB handles COM easily, but not straight DLLs
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

  4. #4
    Join Date
    Jan 2002
    Location
    Halifax, NS, Canada
    Posts
    985
    Unfortunatly I have little experience with JNI in java, but I'll research it a bit more.

    I'll also look up Java and COM.

  5. #5
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163
    > Maybe dlorde might be a little more help here.

    Sorry, my COM days were long-ago, before I got into Java...

    I'm not really sure what the problem is. Why do you need to call C++ functions from Java and vice-versa? what about the other languages?

    If each client runs a local language application that competes with other clients via the C++ server, why not use the server to supply any common processing facilities that all clients need?

    For example, Web Services (e.g. .NET) would allow the server to supply common processing facilities to each client on request, alternatively you could devise your own game protocol using a simple communications interface, such as RPC or sockets.


    All that is needed for evil to triumph is for good men to do nothing...
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  6. #6
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588
    Originally posted by dlorde
    I'm not really sure what the problem is. Why do you need to call C++ functions from Java and vice-versa? what about the other languages?
    I'm basically looking for a way to handle communication between different languages as easily as possible. "call a C++ function" just means that the java program should be able to initiate a communication with the C++ server, send it some data and get feedback.
    If each client runs a local language application that competes with other clients via the C++ server, why not use the server to supply any common processing facilities that all clients need?
    If possible, I'd like to use a common interface for all languages. If Java communicates with web services, VB communicates via COM and C++ communicates as a DLL then writing the server is going to be a mess.
    For example, Web Services (e.g. .NET) would allow the server to supply common processing facilities to each client on request, alternatively you could devise your own game protocol using a simple communications interface, such as RPC or sockets.
    Yes, maybe sockets are the easiest way. The solution defaults to this one if there is no possibility in Java to use local COM objects and create some of its own.
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured