Conversion of Delphi code to Java [closed]
Asked Answered
S

4

6

Does a parser exist for Delphi which can be used to convert the Delphi code into Java code automatically?

Servant answered 30/9, 2009 at 7:45 Comment(3)
I strongly doubt it. Maybe a compiler that compiles Delphi code for the JVM, along with a library implementing a wrapper around Java's stdlib.Lohrman
Look at Remobjects Oxygene en.wikipedia.org/wiki/Oxygene_%28programming_language%29 the latest release allows compiling Pascal code into Java bytecode.Waldgrave
Well yes, but Oxygene is not quite Delphi, and there is no Delphi RTL, VCL or FireMonkey, nor any of the used Delphi libraries etc. Anything beyond the most trivial will not easily translate. Rewriting all of the Delphi code to make it compile to Java bytecode with Oxygene might be just as much work as rewriting it to Java directly.Trust
C
7

I am not aware of such a converter, but keep in mind that such conversions will only get you so far.

For instance there's a Java to C# convert that ships with Visual Studio. It does an excellent job, but for anything beyond the most trivial example you still have to do a lot of cleanup/refactoring yourself in my experience. Also, bad code in the original language will usually get converted to just as bad or possible worse code in the new language. So the code will be hard to maintain.

The point is there's no free lunch. Even with a converter you most likely will have to do a significant bit of porting yourself. If that is out of the question (due to time, money, whatever) you may have to rethink the project.

I am sorry I could not point you to a useful tool (hopefully others will) but I have seen these projects a couple of times and people are usually surprised by the cleanup work needed after a conversion.

Corm answered 30/9, 2009 at 7:53 Comment(1)
I know of one successful product that someone decided should be in another language, so they auto-translated it. Worked fine, until someone wanted to add a new feature and NO ONE knew anything about how the code worked now. They lost a year while they re-wrote it again.Gayn
B
3

The best solution I can think of would be: grab a Java-Developer and do some extreme programming (you: reading the Delphi sourcecode and explaining to him what it should do - he: writing all down in Java)

Because even if you find a Delphi-to-Java Converter - it might produce bad sourcecode.

Bozarth answered 30/9, 2009 at 14:17 Comment(0)
P
3

Free Pascal supports compilation for the Java Virtual Machine (JVM):

Java-bytecode target added to the Free Pascal compiler.

A new target has been added to Free Pascal compiler. It is now possible to compile applications to Java bytecode. This means that these Free Pascal applications can run in a Java Virtual Machine (JVM), so that it can run on any platform that has Java support.

However, this target does only support the basic Pascal language and some functionality of the system unit.

Purlin answered 4/3, 2012 at 18:19 Comment(0)
K
1

Before there was a program called Delphi2J to convert, but I couldn't find the link to download it.

Another way:

  1. Try to Convert Delphi code to C# code using the Delphi2CS
  2. Then use VB & C# to Java Converter there is demo, I didn't try it.
Kellerman answered 30/9, 2009 at 8:1 Comment(1)
I tested on an application without GUI and can confirm that Delphi2CS is working quite well and the resulted C# code is quite easy to to transform to Java even manually. Thank you!Dragon

© 2022 - 2024 — McMap. All rights reserved.