How can C/C++ source code and libraries be used in Java? [closed]
开发者_开发问答
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this questionIs there any way that a .c and .h files can be used in eclipse? On a 32 bit xp,using jre1.6. I do not know any C. The code is about 500 lines
Not directly. You would need to know some c to add interface methods to be able to use JNI.
JNI is the key to use c or c++ code.
You can either invoke it using JNA or JNI, JNA generally being the easier one to use.
You'll need to alter your code though by reading up on the two technologies - it's not a magic bullet.
Your best bet is to rewrite the code.
Any kind of automated conversion usually produces unmaintainable code. If you opt for this solution, just pick one of these :
http://tech.novosoft-us.com/product_c2j.jsp
http://www.soften.ktu.lt/~stonis/c2java/
精彩评论