Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imvmc.exe errors when compiling a basic jar file #110

Closed
KevM opened this issue Jul 14, 2022 · 15 comments
Closed

imvmc.exe errors when compiling a basic jar file #110

KevM opened this issue Jul 14, 2022 · 15 comments

Comments

@KevM
Copy link

KevM commented Jul 14, 2022

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 KevM changed the title imvmc.exe errors when imvmc.exe errors when compiling a basic jar file Jul 14, 2022
@wasabii
Copy link
Contributor

wasabii commented Jul 14, 2022

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
Copy link
Contributor

wasabii commented Aug 21, 2022

stale

@wasabii wasabii closed this as not planned Won't fix, can't repro, duplicate, stale Aug 21, 2022
@KevM
Copy link
Author

KevM commented Sep 3, 2022

Still having this problem with the latest release.

@wasabii
Copy link
Contributor

wasabii commented Sep 3, 2022

Post the command line and error message.

@jyotirmayghosh
Copy link

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.

@wasabii
Copy link
Contributor

wasabii commented Nov 8, 2023

-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

@varratna
Copy link

varratna commented Jan 9, 2024

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
Copy link

varratna commented Jan 9, 2024

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

@wasabii
Copy link
Contributor

wasabii commented Jan 9, 2024

@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.

@varratna
Copy link

varratna commented Jan 9, 2024

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.

@wasabii
Copy link
Contributor

wasabii commented Jan 9, 2024

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.

@varratna
Copy link

varratna commented Jan 9, 2024 via email

@varratna
Copy link

varratna commented Jan 10, 2024

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
Copy link

It looks like no reference to .dll

Screenshot 2024-01-11 112108

@varratna
Copy link

varratna commented Jan 11, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants