I built a Java application using Quarkus.
Then I created the JAR file using
mvn clean package
Then I created a .Net Core console application and added the IKVM nuGet packages
and also referenced the jar file in the csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="IKVM" Version="8.11.2" />
<PackageReference Include="IKVM.ByteCode" Version="9.3.3" />
<PackageReference Include="IKVM.Image" Version="8.11.2" />
<PackageReference Include="IKVM.Image.JDK" Version="8.11.2" />
<PackageReference Include="IKVM.Image.JRE" Version="8.11.2" />
<PackageReference Include="IKVM.Maven.Sdk" Version="1.9.2" />
</ItemGroup>
<ItemGroup>
<IkvmReference Include="dbexample-1.0.0.jar" >
<AssemblyName>dbexample</AssemblyName>
<AssemblyVersion>1.0.0</AssemblyVersion>
<AssemblyFileVersion>1.0.0</AssemblyFileVersion>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Sources>DatabaseLib.class</Sources>
<Debug>portable</Debug>
<DelaySign>true</DelaySign>
</IkvmReference>
</ItemGroup>
<ItemGroup>
<None Update="dbexample-1.0.0.jar">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
The problem is that the content of the JAR file is not being displayed in the .Net application, meaning that I cannot access their namespaces as well as classes and methods. I tried using another JAR file, the one coming with the "helloworld" example from IKVM, and it imported the JAR correctly.
I didn't use the IKVMC tool with the JAR file because whenever I try to use the tool with any JAR or DLL I get errors and I believe that the goal of that tool is to generate .Net Assemblies and is not needed to import the JAR into the .Net application. But maybe I'm wrong
I've read a lot of documentation regarding IKVM but I didn't make it work Could I miss something, specially in the Quarkus application that I should have done?
This is the Java application:
package com.example;
import .graalvm.nativeimage.IsolateThread;
public class DatabaseLib {
public static void main(String[] args) {
System.out.println("Hello from GraalVM 21! Main method from DatabaseLib");
}
public static String ConnectToDatabase(IsolateThread thread, int connect) {
return "Hello from Quarkus DLL! " + String.valueOf(connect);
}
public static String DisconnectFromDatabase(IsolateThread thread) {
return "Hello from Quarkus DLL!";
}
public static String DatabasePop(IsolateThread thread) {
return "Hello from Quarkus DLL! DatabasePop";
}
}
My thanks in advance
I tried importing another JAR file, from the IKVM example, the one called "helloworld" and it worked. I checked inside the generated JAR file and the namespace, as well as the methods were being exported, using the command:
jar tf risp-datalayer-app-1.0.0.jar