how to embed C/C++ code in java?

I know a interface named Native interface provided by sun can embed c/c++ code into java but really don't
know how to do that.
Kindly explain in detail.
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.

vegetasharmaAuthor Commented:
Can you write a little addition/subtraction c++
code which I Can run on java?
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

The basic idea goes as:

1) You declare a native method in your class
2) You generate / extract a C/C++ header file from that method
3a) The C/C++ is inside a DLL file so you need to create a wrapper for it.
3b) You write the code yourself (or you can modify it) so you just use the header file and implement the functions you wish
4) Finally you load the generated library from inside your code and call the native method.

Notice: Not all C/C++ Compilers are JNI compatible in which case you need to be carefull.
I find the MinGW-5.1.3 works fine, but the easiest way is using Netbeans.
This tutorial also might come in handy if you decide on netbeans:

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
vegetasharmaAuthor Commented:
Yea , It work fine but I expected the solution by source code.
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.