New IKVM 8.2 & MavenReference for .NET projects

Roughly 2 months ago, a new long-awaited version of IKVM was announced.

The killer feature of the 8.2 release is the support of .NET Core. So, now, IKVM can translate JAR files to .NET Core compatible DLLs. Woohoo!

Last week I migrated to the new IKVM two projects and can share my first impressions:

First impressions

First of all, it works! I am glad to see that project was revived and .NET Core was supported. It really opens up a lot of new possibilities for .NET developers. But, not everything is perfect yet:

  1. No support for JDK higher than JDK 8.
    This means that you cannot use JAR files compiled by JDK 9 for example. It is quite an old limitation, and the project requires an incredible amount of work to catch up with later versions. Everyone can help here šŸ˜‰
  2. IKVM Compiler (IKMVc) is hard to use.
    Currently project ships two compilers (IKVMc): one for .NET Framework and one for .NET Core as well as two sets of runtime libraries for two runtimes. You should use .NET Core version of IKVMc with .NET Core set of runtime libraries to produce .NET Core version of a JAR file.
    Is it confusing and quite hard to use! In most cases, you should not IKVMc use directly anymore, because the project gives you access to MavenReference / MSBuild integration (read further for details).
  3. You should build on Windows with .NET Core 3.1 installed.
    Windows is the only fully supported platform (once again, it only build-time dependency, produced DLLs will work on all platforms including Linux & macOS, and runtimes like .NET 6).
    Linux version almost works, except for Sockets support.
    The macOS version does not exist yet but looks like something is coming

MavenReference

MavenReference is a very cute new addition to the IKVM family of tools that hide from you the complexity of IKVMc. All you need is to edit your csprof/fsproj file and reference to Maven package! (You may think about Maven like a Nuget from Java world)

Here is the sample:

  <ItemGroup>
	<PackageReference Include="IKVM" Version="8.2.1" />
	<PackageReference Include="IKVM.Maven.Sdk" Version="1.0.1" />
	<MavenReference Include="org.apache.opennlp:opennlp-tools" Version="1.9.4" />
  </ItemGroup>
  • IKVM package contains Java runtime libraries that you need to run compiled DLLs
  • IKVM.Maven.Sdk package provides MSBuild integration to use <MavenReference> (like IKVMc, dependencies resolution and etc)
  • org.apache.opennlp:opennlp-tools is actually a reference to the maven package that we want to recompile.

That is all you need to get started using Maven dependencies from .NET Core!

P.S. If something co wrong, just check that run build on Windows and Maven package compiled using JDK 8. JDK version (Build-Jdk-Spec) you can find in the manifest inside of the JAR file, do not confuse it with Bundle-RequiredExecutionEnvironment!

Build-Jdk-Spec: 11
Bundle-RequiredExecutionEnvironment: JavaSE-1.8

14 thoughts on “New IKVM 8.2 & MavenReference for .NET projects

  1. Sergey …IKVM is a super product and you undoubtably have worked very hard on it thus far. However ….(no thanks to) Microsoft who have just made .NET Core 3.1 as ‘out of support’. Is there any chance you could release an IKVM that targets .NET Core 6.0 or .NET Core 7.0? Thanks in advance

  2. Hi !
    Sorry to ask it here but I couldn’t find any valid answer by exploring the web and it seems that you are the only one who made an article on a version of IKVM higher than 8.1 (when ikvmc was still usable in command line).
    I need to convert a java project (with maven) to a .NET4.6.1 dll but the readme in the github project for the 8.6.2 does not detail the process very much so as you said and as I noticed it’s really hard to use now.
    do you know if there is a tutorial or more extensive documentation on the process?

    Thank you very much in advance

      1. Thank you very much, I’ll look into it carefully.
        I work in c#, but whatever, I’m very interested.
        It looks like you are the only one sharing your experience with the new system of ikvmc, so… respect !

      2. Hi again !

        Thank you very much again for the help.

        I cheked your work arround ikvmc and I wasn’t that far.
        I saw that we can continue to use ikvmc.exe as in ikvm 8.1 version but we have to give the ikvm runtime path to the ikvmc (that wasn’t needed with the 8.1). So, i tried and the command works now.
        I just have a few problems now by using the converted dll like a TypeInitializationException with java.lang.Object and IKVM.Runtime.Vfs.VfsTable.

        Did you experienced this problem with the 8.2.1 version of ikvm ?

        Thank you again for your time

  3. Hi Sergey,
    Thanks, so much for the work you’ve done for the community.

    I have an issue -trying to convert a few of my jar files using the ikvmc in CLI, it does it but seems a few files are missing.
    Could you point me to probably where i can download your version of ikmv and maybe an article to really digest how to go about this. I find it a bit tough.

    Thanks.

    1. I shared the link to my code in the previous comment, but if you need dll for new .net the recommended way to do it – using MavenReference.

  4. Hi Sergey, I’m a .Net programmer with little to no java knowledge. Your comment: “If something co wrong, just check that run build on Windows and Maven package compiled using JDK 8. JDK version (Build-Jdk-Spec) you can find in the manifest inside of the JAR file, do not confuse it with Bundle-RequiredExecutionEnvironment!”

    Basically I’m having issues getting started – first hurdle was logging with slf4j (I asked on stack overflow – link in my “website”). I think it’s to do with the class path, but no idea really.

    After I figured out how to get the manifest file for org.slf4j:slf4j-simple (opened the JAR in 7zip), I see the Build-jdk-spec is 20. However it also has the lines:
    X-Compile-Source-JDK: 8
    X-Compile-Target-JDK: 8

    Is that OK? And if it’s not OK, what’s the next step? Or it just wont work?

    My end goal is to use Apache Tika in my .Net project, but the first thing it fails on is loading a slf4j logging provider (i.e. slf4j-simple) so I’m just trying to get that to work first.

    1. Sorry, I completely missed your comment and went on vacation. Have you tried simpler path with MavenReference? Do you have issues with this approach?

Leave a comment