Problems porting Java to J #

I have medium sized Java code (25k lines, 25k lines) in java and would like to port it to work in the CLR environment as well as in the JVM.

Only the main class and several testing utilities are related to the file system or OS. The rest of the code makes extensive use of the common collection APIs, java.util.regex, java.net (but not URL or URLConnection), java.io for encoding / decoding encoding, java.text for normalizing Unicode and org.w3c. dom for XML processing.

Is it possible to get most of the code compilation for both J # and Java, and then delete the rest?

If so, what errors can I encounter?

thanks in advance microphone

+4
source share
3 answers

Check out IKVM: http://www.ikvm.net/

It allows you to run (specially compiled) Java code inside the .Net CLR.

Some of my colleagues have successfully used it with a Java codebase of 1 million + lines of code.

+7
source

Traps:

  • Something like this scares me. The number of really subtle errors awaiting this is enormous.
  • J # only supports Java 1.1.4 AFAIK - bye, etc.
  • Visual Studio 2008 does not support J # - basically this is a dead project.

I suspect that it would actually be easier to rewrite it in C # (including learning C #, if you still don't know this is a joy). You will end up with a more idiomatic library, similar to .NET, if necessary: โ€‹โ€‹if you want another .NET developer to consume your code, they are likely to be much happier with a โ€œcleanโ€ one. NET than one using J #.

The disadvantage is that in the future, any changes must also be made in two places. There is, of course, pain, but I really think that you will have better experience using "normal" .NET.

+4
source

As John pointed out: J # is pretty dead.

Running your (normal) .NET Java code using IKVM may be an alternative though.

+3
source

All Articles