Interfacing between Java & C++

I want to write a gui using Java and then interfacing the gui with a c++ program that will dictate what is shown in the gui. I using unix as my developing platform.

I was thinking of having two seperate processes and then using unix ipc but I'm looking for a closer relationship between the two programs. Would it be possible to link the Java and C++ code?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


>>Would it be possible to link the Java and C++ code?
it is possible.

JNI is a fairly rich programming interface that allows you to call native methods from a Java application.
 JNI is designed to interface with native methods written  in C or C++.
call native methods from a Java application.

u can call Java methods from a native app too.Its a 2 way communication.

from ur login I presume that u r using AIX?
if u want any JNI links other than the standard one provided by Sun at

see these 

This is one of the Best and I used it at Start and also now.... 

look at CodeGuru's Links to other good sites. 

this one is repeating everything they tell but for beginners it looks good.
hi amit(mbormann)
   informative  URL's
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

how do you do?
if u want to pls contact me at

Another approach that you can take is to use CORBA. Place your  C++ in a corba object, and connect it with a java process that has the UI. You will get the two processes that you mentioned, and a more standard approach then unix ipc. You can download and compile many C++ corba orbs (try orbacus by ooc). What unix platform are you using?

I am seeing gladio first time in three months in posting a comment.
[ravindra76] You were not reading all the questions I think. I am posting comments all the time. I must say however, that there are couple of very fast answering people here (heyhey, vladi21 etc.). So,  many times when I read a question there is nothing left to say...
But I'll post more - to make you happy  ;-)
Fast answering is just the half of it. I start formulating an answer and find comments where there were none before I even post it. Methinks I think too much...

Anyway...just as a small simple example of JNI...

The following is a brief summary of the steps involved in writing and using native methods. Let's say you wanted to create a Java class that needed a native method for computing Fast Fourier Transforms (fft's) for higher performance. You would first have to create a Java wrapper class that declared the native methods so that other Java programs could instantiate the FFT class and use those methods. For example the wrapper class might like this:

        class FFT {
                public native void doFFT();
                static {

Then you need to generate appropriate header files and stub files using the javah utility which comes with the JDK. You create the accompanying header file using 'javah FFT' and the stub file using 'javah -stubs FFT'. These stub files contain the appropriate function declarations that you need to use in your C routines. For example, the doFFT function declaration would come out looking something like:
        void FFT_doFFT(struct HFFT *this);

You then need to compile your routines using the above declarations and package them into a DLL or dynamic library using the appropriate compiler flags:
on Solaris:

                cc -I/usr/local/java/include -I/usr/local/java/include/solaris
                        fft_routines.c FFT.c -o

on win95: (using microsoft visual C++)

                cl FFT.c fft_routines.c -Fefft.dll -MD -LD javai.lib

This creates the appropriate runtime library for the Java program to use. You are then free to use the FFT class in your Java programs like any other Java classes.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
  Why not just use very simple way: FILE, and old but always usefull IPC technic? In most case ,it's simple but enough!
zhongbing, I think Aixsar has already considered this but is looking for a closer level of integration...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.