ikvm icon indicating copy to clipboard operation
ikvm copied to clipboard

imvmc.exe errors when compiling a basic jar file

Open KevM opened this issue 3 years ago • 1 comments
trafficstars

I am having problems getting ikvmc.exe to compile a rudimentary jar file. Here is the command line and result.

.\IKVMc.exe .\hello.jar                                                                                                       pwsh  09:57:23 
IKVM.NET Compiler (8.2.0-prerelease.392)
Copyright © 2022 Jeroen Frijters, Windward Studios, Jerome Haltom, Shad Storhaug


*** INTERNAL COMPILER ERROR ***

PLEASE FILE A BUG REPORT FOR IKVM.NET WHEN YOU SEE THIS MESSAGE

ikvmc, Version=8.2.0.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58
C:\Users\scoun\Downloads\testing\
3.1.25 64-bit

System.IO.FileNotFoundException: Reference assemblies directory: C:\Users\packs\Downloads.Ref\3.1.0\ref\netcoreapp3.1
   at IKVM.Reflection.Universe.BuildRefDirFrom(String runtimeDir) in D:\a\ikvm\ikvm\IKVM.Reflection\Universe.cs:line 180
   at IKVM.Reflection.Universe.get_ReferenceAssembliesDirectory() in D:\a\ikvm\ikvm\IKVM.Reflection\Universe.cs:line 156
   at IKVM.Reflection.Universe.DefaultResolver(String refname, Boolean throwOnError) in D:\a\ikvm\ikvm\IKVM.Reflection\Universe.cs:line 842
   at IKVM.Reflection.Universe.Load(String refname, Module requestingModule, Boolean throwOnError) in D:\a\ikvm\ikvm\IKVM.Reflection\Universe.cs:line 799
   at IKVM.Internal.AssemblyResolver.Init(Universe universe, Boolean nostdlib, IList`1 references, IList`1 userLibPaths) in D:\a\ikvm\ikvm\ikvmc\IKVM\Internal\AssemblyResolver.cs:line 93
   at ikvmc.IkvmcCompiler.Compile(String[] args) in D:\a\ikvm\ikvm\ikvmc\IkvmcCompiler.cs:line 178
   at ikvmc.IkvmcCompiler.Main(String[] args) in D:\a\ikvm\ikvm\ikvmc\IkvmcCompiler.cs:line 112

I created the jar file from a basic hello world.

class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Jar creation build against openjdk 11.0.12

javac hello.java
jar hello.jar helloworld.class

I am pretty much ignorant of java development in general so potentially I am missing something basic. I do know .NET pretty well and fostered a library that used IKVM for exposing a java library on dotnet. I am attempting to get this working on dotnet core but the ikvmc.exe step fails with a similar error so I tried this basic example to debug.

KevM avatar Jul 14 '22 15:07 KevM

This seems like an odd version to be using: 8.2.0-prerelease.392.

8.2.0 was released almost two weeks ago.

Also, ikvmc will require that all required dependent DLL files are specified using -reference. That includes IKVM.Java from the bin package. And it requires -runtime be specified to to point to IKVM.Runtime.

This is all much easier using IKVM.Maven.Sdk or IkvmReference in your build files, however.

wasabii avatar Jul 14 '22 17:07 wasabii

stale

wasabii avatar Aug 21 '22 18:08 wasabii

Still having this problem with the latest release.

KevM avatar Sep 03 '22 20:09 KevM

Post the command line and error message.

wasabii avatar Sep 03 '22 20:09 wasabii

Hey @wasabii I am trying out IKVM to convert jar to dll. I started with ikvm-7.2 and later came across the latest version ikvm-8.7.0.

I am trying to convert from the command line. Command -> ikvmc -target:library -out:offlinepos.dll -r:offlinepos.jar Error ->

IKVM.Tools.Importer (8.7.0+Branch.tags-8.7.0.Sha.8fd37569453a3889205c22f1547e0609545cab4a)
Copyright © 2023 Jeroen Frijters, Windward Studios, Jerome Haltom, Shad Storhaug


*** INTERNAL COMPILER ERROR ***

PLEASE FILE A BUG REPORT FOR IKVM.NET WHEN YOU SEE THIS MESSAGE

IKVM.Tools.Importer, Version=8.7.0.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\
4.0.30319.42000 64-bit

System.InvalidOperationException: PE image does not have metadata.
   at System.Reflection.PortableExecutable.PEReader.GetMetadataBlock()
   at System.Reflection.Metadata.PEReaderExtensions.GetMetadataReader(PEReader peReader, MetadataReaderOptions options, MetadataStringDecoder utf8Decoder)
   at IKVM.Tools.Importer.StaticCompiler.GetAssemblyNameIfCoreLib(String path) in /_/src/IKVM.Tools.Importer/StaticCompiler.cs:line 101
   at IKVM.Tools.Importer.StaticCompiler.FindCoreLibName(IList`1 references, IList`1 libpaths) in /_/src/IKVM.Tools.Importer/StaticCompiler.cs:line 78
   at IKVM.Tools.Importer.StaticCompiler.Init(Boolean nonDeterministicOutput, IList`1 libpaths) in /_/src/IKVM.Tools.Importer/StaticCompiler.cs:line 60
   at IKVM.Tools.Importer.IkvmImporterInternal.Compile(String[] args) in /_/src/IKVM.Tools.Importer/IkvmImporterInternal.cs:line 180
   at IKVM.Tools.Importer.IkvmImporterInternal.Execute(String[] args) in /_/src/IKVM.Tools.Importer/IkvmImporterInternal.cs:line 111

The jar is compiled with java 8. Also, is there any alternative way to convert using Visual Studio.

jyotirmayghosh avatar Nov 08 '23 07:11 jyotirmayghosh

-r is for adding a reference to an assembly. I believe the input files have no argname.

Yes, there is copious documentation on using IkvmReference on the Readme

wasabii avatar Nov 08 '23 14:11 wasabii

Hey @wasabii I am trying out IKVM to convert jar to dll. I started with latest version IKVM-8.7.3-bin-net6.0.

I am trying to convert from the command line. Command -> ikvmc -target:library hha-pricer-application-1.12.0.jar -out:hha-pricer-application-1.12.0.dll Error ->

IKVM.Tools.Importer (8.7.3+Branch.tags-8.7.3.Sha.93a12b1dfa8e91459d36916cbdb2425e68643b03) Copyright c 2023 Jeroen Frijters, Windward Studios, Jerome Haltom, Shad Storhaug

Error: core library not found

*** INTERNAL COMPILER ERROR ***

PLEASE FILE A BUG REPORT FOR IKVM.NET WHEN YOU SEE THIS MESSAGE

IKVM.Tools.Importer, Version=8.7.3.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58 C:\Users\Lenovo\Downloads\IKVM-8.7.3-bin-net6.0\ikvmc\net6.0\win-x64
6.0.25 64-bit

System.IO.FileNotFoundException: System.Runtime at IKVM.Reflection.Universe.Load(String refname, Module requestingModule, Boolean throwOnError) in //src/IKVM.Reflection/Universe.cs:line 564 at IKVM.Tools.Importer.AssemblyResolver.Init(Universe universe, Boolean nostdlib, IList1 references, IList1 userLibPaths) in //src/IKVM.Tools.Importer/AssemblyResolver.cs:line 84 at IKVM.Tools.Importer.IkvmImporterInternal.Compile(String[] args) in //src/IKVM.Tools.Importer/IkvmImporterInternal.cs:line 181 at IKVM.Tools.Importer.IkvmImporterInternal.Execute(String[] args) in //src/IKVM.Tools.Importer/IkvmImporterInternal.cs:line 111

The System.Runtime.dll is already present in IKVM-8.7.0-bin-net6.0\ikvmc\net6.0\win-x64 folder

Is there any other way to convert the jar to .dll seamlessly.

varratna avatar Jan 09 '24 14:01 varratna

Hey @wasabii I am trying out IKVM to convert jar to dll. I started with ikvm-7.2 and later came across the latest version ikvm-8.7.0.

I am trying to convert from the command line. Command -> ikvmc -target:library -out:offlinepos.dll -r:offlinepos.jar Error ->

IKVM.Tools.Importer (8.7.0+Branch.tags-8.7.0.Sha.8fd37569453a3889205c22f1547e0609545cab4a)
Copyright © 2023 Jeroen Frijters, Windward Studios, Jerome Haltom, Shad Storhaug


*** INTERNAL COMPILER ERROR ***

PLEASE FILE A BUG REPORT FOR IKVM.NET WHEN YOU SEE THIS MESSAGE

IKVM.Tools.Importer, Version=8.7.0.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\
4.0.30319.42000 64-bit

System.InvalidOperationException: PE image does not have metadata.
   at System.Reflection.PortableExecutable.PEReader.GetMetadataBlock()
   at System.Reflection.Metadata.PEReaderExtensions.GetMetadataReader(PEReader peReader, MetadataReaderOptions options, MetadataStringDecoder utf8Decoder)
   at IKVM.Tools.Importer.StaticCompiler.GetAssemblyNameIfCoreLib(String path) in /_/src/IKVM.Tools.Importer/StaticCompiler.cs:line 101
   at IKVM.Tools.Importer.StaticCompiler.FindCoreLibName(IList`1 references, IList`1 libpaths) in /_/src/IKVM.Tools.Importer/StaticCompiler.cs:line 78
   at IKVM.Tools.Importer.StaticCompiler.Init(Boolean nonDeterministicOutput, IList`1 libpaths) in /_/src/IKVM.Tools.Importer/StaticCompiler.cs:line 60
   at IKVM.Tools.Importer.IkvmImporterInternal.Compile(String[] args) in /_/src/IKVM.Tools.Importer/IkvmImporterInternal.cs:line 180
   at IKVM.Tools.Importer.IkvmImporterInternal.Execute(String[] args) in /_/src/IKVM.Tools.Importer/IkvmImporterInternal.cs:line 111

The jar is compiled with java 8. Also, is there any alternative way to convert using Visual Studio.

Hey Did you get the solution for the issue you were facing

varratna avatar Jan 09 '24 14:01 varratna

@varratna

-r is for referencing the dependent .NET assemblies.

You've used it to reference a JAR file. So it is breaking saying it isn't a PE image with metadata (a .NET assembly).

We strongly recommend using IkvmReference or MavenReference.

wasabii avatar Jan 09 '24 15:01 wasabii

Hey @wasabii I am trying out IKVM to convert jar to dll. I started with latest version IKVM-8.7.3-bin-net6.0.

I am trying to convert from the command line. Command -> ikvmc -target:library hha-pricer-application-1.12.0.jar -out:hha-pricer-application-1.12.0.dll Error ->

IKVM.Tools.Importer (8.7.3+Branch.tags-8.7.3.Sha.93a12b1dfa8e91459d36916cbdb2425e68643b03) Copyright c 2023 Jeroen Frijters, Windward Studios, Jerome Haltom, Shad Storhaug

Error: core library not found

*** INTERNAL COMPILER ERROR ***

PLEASE FILE A BUG REPORT FOR IKVM.NET WHEN YOU SEE THIS MESSAGE

IKVM.Tools.Importer, Version=8.7.3.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58 C:\Users\Lenovo\Downloads\IKVM-8.7.3-bin-net6.0\ikvmc\net6.0\win-x64 6.0.25 64-bit

System.IO.FileNotFoundException: System.Runtime at IKVM.Reflection.Universe.Load(String refname, Module requestingModule, Boolean throwOnError) in //src/IKVM.Reflection/Universe.cs:line 564 at IKVM.Tools.Importer.AssemblyResolver.Init(Universe universe, Boolean nostdlib, IList1 references, IList1 userLibPaths) in //src/IKVM.Tools.Importer/AssemblyResolver.cs:line 84 at IKVM.Tools.Importer.IkvmImporterInternal.Compile(String[] args) in //src/IKVM.Tools.Importer/IkvmImporterInternal.cs:line 181 at IKVM.Tools.Importer.IkvmImporterInternal.Execute(String[] args) in //src/IKVM.Tools.Importer/IkvmImporterInternal.cs:line 111

The System.Runtime.dll is already present in IKVM-8.7.0-bin-net6.0\ikvmc\net6.0\win-x64 folder

Is there any other way to convert the jar to .dll seamlessly.

varratna avatar Jan 09 '24 16:01 varratna

As I said, you should favor using IkvmReference or MavenReference.

Else, you will need to add a -r argument for every assembly that forms the reference assembly pack for runtime you are intending to target. For .NET Framework this will be all of the reference assemblies installed by the various targeting packs.

For Core, this will be all of the assemblies for the Microsoft.NETCore.App.Ref pack of the specific version of .NET Core you want to target.

wasabii avatar Jan 09 '24 16:01 wasabii

Hi Jerome Haltom,

Thanks for your reply .

I shall try using IkvmReference or MavenReference.

I just tried using the -r argument and execute the below command , but still it was giving me the same error.

I was expecting an error but it should have referred to some other assembly from the Microsoft.NETCore.App\6.0.25 folder instead of System.Runtime.dll

Am I doing something wrong , can you verify the below command.

Command - ikvmc -reference:"C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.25\System.Runtime.dll" -out:hha-pricer-application-1.12.0.dll hha-pricer-application-1.12.0.jar

Erorr - Error: core library not found *** INTERNAL COMPILER ERROR *** PLEASE FILE A BUG REPORT FOR IKVM.NET WHEN YOU SEE THIS MESSAGE IKVM.Tools.Importer, Version=8.7.3.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58 C:\Users\Lenovo\Downloads\IKVM-8.7.3-bin-net6.0\ikvmc\net6.0\win-x64
6.0.25 64-bit System.IO.FileNotFoundException: System.Runtime at IKVM.Reflection.Universe.Load(String refname, Module requestingModule, Boolean throwOnError) in //src/IKVM.Reflection/Universe.cs:line 564 at IKVM.Tools.Importer.AssemblyResolver.Init(Universe universe, Boolean nostdlib, IList1 references, IList1 userLibPaths) in //src/IKVM.Tools.Importer/AssemblyResolver.cs:line 84 at IKVM.Tools.Importer.IkvmImporterInternal.Compile(String[] args) in //src/IKVM.Tools.Importer/IkvmImporterInternal.cs:line 181 at IKVM.Tools.Importer.IkvmImporterInternal.Execute(String[] args) in //src/IKVM.Tools.Importer/IkvmImporterInternal.cs:line 111

Appreciate your help!

Thanks, varratna


From: Jerome Haltom @.> Sent: Tuesday, January 9, 2024 10:08 PM To: ikvmnet/ikvm @.> Cc: varratna @.>; Mention @.> Subject: Re: [ikvmnet/ikvm] imvmc.exe errors when compiling a basic jar file (Issue #110)

As I said, you should favor using IkvmReference or MavenReference.

Else, you will need to add a -r argument for every assembly that forms the reference assembly pack for runtime you are intending to target. For .NET Framework this will be all of the reference assemblies installed by the various targeting packs.

For Core, this will be all of the assemblies for the Microsoft.NETCore.App.Ref pack of the specific version of .NET Core you want to target.

— Reply to this email directly, view it on GitHubhttps://github.com/ikvmnet/ikvm/issues/110#issuecomment-1883394988, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AO6IM3X7O5FEUOADY7BD5QLYNVXB7AVCNFSM53SS2JNKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBYGMZTSNBZHA4A. You are receiving this because you were mentioned.

varratna avatar Jan 09 '24 17:01 varratna

I get the below error , I added the <IkvmReference manually by editing the csproj , <IkvmReference tag should have auto populated while typing

Screenshot 2024-01-10 120015

varratna avatar Jan 10 '24 06:01 varratna

It looks like no reference to .dll

Screenshot 2024-01-11 112108

varratna avatar Jan 11 '24 05:01 varratna

Hi

I am able to convert the java.jar file to .dll file I am trying to access the main class and create and object to call the respective methods

but I am not able to get the namespace of the main class in the .dll

It did not give any error or warning . I used the IKVM reference method.

eg hha-pricer-application-1.12.0.jar\gov\cms\fiss\pricers\hha - my main class in java.jar - this namespace and class not accessible in .net (.dll) other folder structure hha-pricer-application-1.12.0.jar\com - these namespace and classes are accessible hha-pricer-application-1.12.0.jar\nonapi\io\github\classgraph - these namespace and classes are accessible

Exe net6.0 enable enable

can you help me out in this

Thanks, varratna


From: Jerome Haltom @.> Sent: Tuesday, January 9, 2024 10:08 PM To: ikvmnet/ikvm @.> Cc: varratna @.>; Mention @.> Subject: Re: [ikvmnet/ikvm] imvmc.exe errors when compiling a basic jar file (Issue #110)

As I said, you should favor using IkvmReference or MavenReference.

Else, you will need to add a -r argument for every assembly that forms the reference assembly pack for runtime you are intending to target. For .NET Framework this will be all of the reference assemblies installed by the various targeting packs.

For Core, this will be all of the assemblies for the Microsoft.NETCore.App.Ref pack of the specific version of .NET Core you want to target.

— Reply to this email directly, view it on GitHubhttps://github.com/ikvmnet/ikvm/issues/110#issuecomment-1883394988, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AO6IM3X7O5FEUOADY7BD5QLYNVXB7AVCNFSM53SS2JNKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBYGMZTSNBZHA4A. You are receiving this because you were mentioned.Message ID: @.***>

varratna avatar Jan 11 '24 11:01 varratna