1

Possible Duplicate:
Convert .c to .java

Is there any online free tool for C/C++ to Java?

I searched on the internet but couldnt find a converter C/C++ to Java. In adddition, how can I use header files in converting process to Java.

Community
  • 1
  • 1
Günay Gültekin
  • 4,486
  • 8
  • 33
  • 36
  • 4
    You couldn't have searched very hard. The [second hit](http://download.cnet.com/C-To-Java-Converter/3000-2213_4-10080009.html) on my default search engine turned up trumps for C. But *why* are you trying to do this? – johnsyweb Jan 22 '12 at 09:32
  • before I post this question I searched and didnt find this question , Trevor – Günay Gültekin Jan 22 '12 at 09:52

2 Answers2

5

If the code cannot be easily understood, your best option may be to use JNI This allows you to call C code from Java without altering it. You are likely to need to write come bridge code to copy data from the Java world to the C world, but you shouldn't need to change the original C itself.


It is hard to be specific with such a broad question. What you can do is:

  • Turn headers into interfaces and classes.
  • Turn source class into java files.
  • Use the same object a method names where possible.
  • Use java's signed values where you currently have unsigned, with work arounds (sometimes none are required)
felixd
  • 383
  • 2
  • 7
  • 20
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • as I wrote to Roi, and also I have a homework , I have to make programme and I used these code that is given from my university teacher, in my homework. – Günay Gültekin Jan 22 '12 at 09:42
  • 3
    If you code cannot be realistically understood, a computer is going to find it harder to understand. You best option may be to use JNI. – Peter Lawrey Jan 22 '12 at 09:42
4

A tool like that would be extremely large and bloated. The best way to convert C/C++ to Java is by hand.

ra4king
  • 594
  • 3
  • 12
  • I have codes C/C++ and these are very long to understand and also I think it takes long time to convert by hand :// – Günay Gültekin Jan 22 '12 at 09:36
  • 2
    If the code you're starting from is hard to understand, I'm pretty sure the resulting code will most likely be harder to understand and maybe even unmaintainable. I don't think there's an easy way out. – Bart Jan 22 '12 at 09:39