Search code examples
javaphpc++java-native-interface

Connecting Java , C++ and PHP to each other


I want to code my web-service in java....but what if i can write my main code in c++ & then access via JNI to use in java and is it efficient or not ? Secondly , I have to create a website and again that c++ code will be used to fetch data but website will be in php..is that possible...& how ?

Please also suggest me if I am going wrong...? or Some other way to do this thing...!

implementation diagram

this is the implementation diagram...is it possible & also efficient or not..?


Solution

  • Is this possible? Yes.

    Is this efficient? Arguable, but I would say no.

    I would suggest that your best bet is to use only one language for your web application. All three of C++, Java, and PHP have great web service capabilities. If you have to add so many layers of technology, managing your application will quickly become a nightmare.

    EDIT

    Since you are creating a web service for an Android app, I would advise that you write it in Java. This is because you can take advantage of code reuse, and is also helpful if you want to add developers to your team.

    PHP and C++ are good choices as well. I personally prefer PHP in this scenario, due to the simplicity of setup. I would only choose C++ over PHP if I had some previous code that is reusable, so I do not need to port over any business logic.

    From there, you can use build an Android application to talk to your web service, as well as create the front end for your website.