Your best bet is to rewrite the code.
Any automated conversion would, at best, yield poor-quality and unmaintainable code.
Is the C to Java converter free?
Is the C++ to Java converter free?
Can I also convert Java back to C++?
Your best bet is to rewrite the code.
Any automated conversion would, at best, yield poor-quality and unmaintainable code.
The C view of the world does not mix well with the Java view of the world. If you really want to compile to a form executable by Java, have a look at NestedVM - http://nestedvm.ibex.org/ - which is a cross compiler compiling to a MIPS-dialect which can then easily be "run" in Java either through interpretation or by conversion to actual bytecode reflecting the original MIPS-instructions.
I would recommend getting a Java version of the code.
It's going to be challenging to convert a C program into Java automatically. The differences between C and Java means that you can't just convert line by line. A few example:
- C does not support classes, but classes are a fundamental concept of Java.
- C has a huge pointer syntax, Java doesn't.
There are many, many differences between C and Java, so I doubt that any program will do a good job of the conversion.
That said, there are a few project thats attempt this:
http://www.soften.ktu.lt/~stonis/c2java/
http://tech.novosoft-us.com/product_c2j.jsp
If you want to run it as Java you will have to have a JVM!
As for translation, try looking at NestedVM.
EDIT: Your title says one thing, your question asks the opposite. This answers the question C โ Java question you originally asked.