This discussion is archived
6 Replies Latest reply: Feb 8, 2011 12:00 PM by jschellSomeoneStoleMyAlias RSS

JNI interface and C++ server

837527 Newbie
Currently Being Moderated
Hi Friends,
My current product is a combination of a C++ application server and Java Web server. Product's web "User interface" is JAVA applet based which takes care of configuration management. C++ server and JAVA server communicate using JNI. I wanted to know that is this a good design? Should we separate the C++ server and JAVA server and make them to communicate using TCP/IP or any other IPC? Looking at the guidelines provided at "The Java™ Native
Interface Programmer’s Guide and Specification" it looks that JNI should be used to call lightweight native code. Much information passing from/to should be avoided.
Your comments will be greatly appreciated!

~ Vikram

Edited by: 834524 on Feb 7, 2011 6:56 AM
  • 1. Re: JNI interface and C++ server
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    Since you can't have a "server" in both C++ and Java and use JNI between them obviously something is at least wrong with your description.

    Regardless of that I wouldn't use JNI unless there was something absolutely preventing me from doing it any other way.
  • 2. Re: JNI interface and C++ server
    837527 Newbie
    Currently Being Moderated
    My product provies
    - Product configuration/policy management by exposing a web console(https). We have a Java web server which takes care of this functionality.
    - C++ server takes care of completely different functionality.

    both are talking to each other using JNI.

    are their any specific reasons that you will avoid using JNI?

    ~ Vikram S
  • 3. Re: JNI interface and C++ server
    EJP Guru
    Currently Being Moderated
    are their any specific reasons that you will avoid using JNI?
    That's the wrong question. Are there any specific reaons you think have to use it?

    In fact if these are separate executables you don't have any choice but to use TCP/IP. JNI is a way to call a C/C++ library. Not a way to interact with a separate process.
  • 4. Re: JNI interface and C++ server
    837527 Newbie
    Currently Being Moderated
    I guess I have explained how my product is using JNI. In that context, is it right place to use JNI?

    Edited by: 834524 on Feb 8, 2011 1:43 AM
  • 5. Re: JNI interface and C++ server
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    VIKRAM wrote:
    My product provies
    - Product configuration/policy management by exposing a web console(https). We have a Java web server which takes care of this functionality.
    - C++ server takes care of completely different functionality.
    So you have a C++ server which provides a management interface implemented via Java.
    both are talking to each other using JNI.

    are their any specific reasons that you will avoid using JNI?
    Because I typically start with a java server which would be talking to C++. And if C++ pointer bugs show up it will cause the server to crash. I don't want that to happen.

    And it is a lot easier to debug/unit test/test a java application and do the same to a C++ application (separate application.) The fact that they provide a communication idiom is just a factor in testing each.

    That said for your case since it is a C++ server whether it crashes or not depends entirely on the skills of the C++ programmers and how well they test. If it crashes then the cause won't be Java. So that part doesn't matter.
  • 6. Re: JNI interface and C++ server
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    VIKRAM wrote:
    I guess I have explained how my product is using JNI. In that context, is it right place to use JNI?
    Since all you are doing is the management GUI I doubt there is any value in making them separate.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points