Tutorial :Are there any programs out there that will convert Java code to C++?



Question:

Are there any programs out there that will convert Java code to C++?


Solution:1

Java is a completely different language to C++. The code will probably have to be completely rewritten from scratch. Even if there is a Java to C++ compiler:

  • It wouldn't work on all Java code.
  • It would not write code that looks like it is written by a C++ programmer.
  • It would probably not use the ordinary C++ or STL types so even if it is valid C++ it wouldn't integrate well with any other code.

You can compile some Java code to native code. Maybe that would be a better approach for you.


Solution:2

I've used this utility with basic projects:

http://www.euclideanspace.com/software/language/xes/userGuide/convert/javaToCpp/index.htm


Solution:3

erotsppa - i wasn't aware of any until browsing this question. we had researched some java to c# tools a few years back with varied success.

anyway, a google search (which i'm sure you've done) turned up a few interesting results:

http://www.euclideanspace.com/software/language/xes/userGuide/convert/javaToCpp/index.htm http://www.scicontrols.com/R2J.htm

jim


Solution:4

There could be potentially.

But the styles of the two languages are so different that the resulting C++ code would look very none C++ like and as such would be hard to maintain.

The real question is why yuo are trying to do this?


Solution:5

There's the JC Virtual Machine which translates Java bytecode to C, which is compiled and run: http://jcvm.sourceforge.net/

If you just want to use a Java library in a C++ application (or vice versa), then you should consider gcj from the GNU compiler collection instead. It's a java->native code compiler. The C++ compiler has specific extensions to interoperate with the code compiled with gcj, which means you can basically use a module written in Java as if it was written in C++.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »