简体   繁体   中英

Converting Borland C++ code to Java code

I've got some 30 year old code, written in C++ (I've been told that's what it was written in, I've no evidence of this), that I'd like to convert to Java.

Is this possible to do automatically?

I've come across this :- http://www.webdeveloper.com/forum/showthread.php?5071-C-to-Java-Converters

which seems to indicate it can be done. Going on a further search for C2J++, gives this example code :- http://jcs.mobile-utopia.com/jcs/6309_C2J++.java

This code seems far to short (in my limited opinion) to actually convert C++ into Java.

I think the best you can do is do it manually. The reason? You will understand what the code does.

If you use any tool, you can be sure that in your case, there are going to be errors. And searching for the errors afterwards will be a hell of work.

It is very hard to say "Yes, it will work", since there are so many variables.

The amount of code you have matters. If you have a few files the do it manually. If you have thousands of files, then aim for a converter. However, don't expect converters to do all the job. They will always do a basic transformation. You are expected to improve it.

The usage matters. What is the C code doing? Is it mission critical? Is is low level? Are there any assembly instructions in the code?

"This code seems far to short". Is that in functionality or lines of code? If the code is in fact very short it might be easier to just re-write it.

Why Java or C++, and why do you need to convert it at all? If you know Java or C++ then it would be simpler to understand C, which makes me think you don't know Java or C++. If this is the case, then you will be trading six for half a dozen. Maybe your time would be better invested learning C?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM