• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 688
  • Last Modified:

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.
0
vegetasharma
Asked:
vegetasharma
3 Solutions
 
oleberCommented:
0
 
vegetasharmaAuthor Commented:
Can you write a little addition/subtraction c++
code which I Can run on java?
0
 
oleberCommented:
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
ansi-boyCommented:
0
 
NelliosCommented:
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
case:
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: http://www.netbeans.org/kb/55/beginning-jni-part1.html
0
 
vegetasharmaAuthor Commented:
Yea , It work fine but I expected the solution by source code.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now