Firstly, when it comes to conversion from language 'X' to language 'Y', then no program can beat human intentions/efforts.
For the above case Java to C++ conversion can be done using programs such as TanglibleSoftware. But for some language constructs which are only supported in Java but not in C++, some work around is surely needed.
Consider case: User 'A' hands over his source code to program 'ABCD' for conversion from language 'X' to 'Y', and he assumes to get the result(exact converted code with same behavior) in bare minimal efforts, then user 'A' is calling for a failure.
I will not go into syntactic differences between Java & C++, but if one has a good grasp on programming then for unsupported constructs of language 'X', code can always be written to perform those operations in language 'Y' successfully.
Machines can only understand code, but meaning has to be construed by Humans.
But this may not be constrained if we consider artificial intelligence into this context or some 'xyz' technology in near future.
My answer is based on my experience, I am not affiliated to TanglibleSoftware by any means, the above software worked for me, with some efforts made. It might not have worked for some other users.
Answer from Viktor Wolf on Stack ExchangeFirstly, when it comes to conversion from language 'X' to language 'Y', then no program can beat human intentions/efforts.
For the above case Java to C++ conversion can be done using programs such as TanglibleSoftware. But for some language constructs which are only supported in Java but not in C++, some work around is surely needed.
Consider case: User 'A' hands over his source code to program 'ABCD' for conversion from language 'X' to 'Y', and he assumes to get the result(exact converted code with same behavior) in bare minimal efforts, then user 'A' is calling for a failure.
I will not go into syntactic differences between Java & C++, but if one has a good grasp on programming then for unsupported constructs of language 'X', code can always be written to perform those operations in language 'Y' successfully.
Machines can only understand code, but meaning has to be construed by Humans.
But this may not be constrained if we consider artificial intelligence into this context or some 'xyz' technology in near future.
My answer is based on my experience, I am not affiliated to TanglibleSoftware by any means, the above software worked for me, with some efforts made. It might not have worked for some other users.
Something like this is not really posible, since there is concepts and keywords in Java without equivalents in C++. For example synchronized, package or instanceof can´t be translated from Java to C++. Even final has not always the same meaning as const.
This is possible, but extremely difficult - for starters, you would need to integrate a garbage collector with your C source. There are a few projects that attempt this, e.g. Toba, but they're unreliable and no longer maintained. Usually you'll find somebody attempting something like this in their Master's thesis, after which it is quickly abandoned.
If you're doing this to try to speed up your program, then don't - Java is already pretty fast compared to natively compiled code (although it tends to use quite a bit more memory), and your translated C code is not going to be able to take full advantage of the C language.
Use Java2C: A translator from Java to C language especially for embedded and fast realtime applications, including a javalike runtime System in C.
http://sourceforge.net/projects/java2c/