ikvmnet / ikvm

A Java Virtual Machine and Bytecode-to-IL Converter for .NET
Other
1.28k stars 121 forks source link

Is command line compilation via ikvmc.exe no longer supported when statically converting Java bytecode to CIL? #613

Closed kdaek21 closed 1 week ago

kdaek21 commented 3 weeks ago

I checked the contents of the comment that said to refer to 'https://github.com/orgs/ikvmnet/discussions/463' in the #612 I registered,

I saw the distinction IKVM.Runtime.Launcher.Run (string main, bool jar, string [] args, string rarg, IDictionary<string, string>properties), and in the comment there was something about Launcher, so I tried static conversion using ikvmc on the command line to see if the Spring Boot launcher part would be converted to IKVM.Runtime.Launcher.Run when using ikvmc for static conversion, but

Core library not found. Make sure the appropriate reference assemblies for the target environment are included. It only gives an error and does not convert. (It is the same even if I make a simple sample)

I looked it up and found that a similar issue was registered before, so I checked and it said to use ikvmReference. When I checked using ikvmReference, it seems to be a method of using jar files as libraries for .NET projects using Visual Studio.

Is there no longer a way to convert a class that contains a (Java) main function or a Java jar file that contains this class into a CIL exe file using ikvmc?

The IKVM tools used are IKVM-8.10.3-tools-net472-win-x64.

wasabii commented 3 weeks ago

It is. But there are a lot of options you need to add. -reference to the ref assemblies of the runtime version you want to bind to.

kdaek21 commented 2 weeks ago

I found the default parameters for net472 version. If you do it like below, the conversion will work.. However, since only the assembly is created, the remaining necessary files must be created or copied separately to ensure normal operation. (Except for special cases such as Spring Boot)

ikvmc -r:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll" -r:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.dll" -runtime:"D:\Java\ikvm-jre8-net472\bin\IKVM.Runtime.dll" [classOrjar1] ... [classOrJarN]

wasabii commented 2 weeks ago

Those are possible paths. But probably not the ones you want. When building you probably want to bind against the reference assemblies from the appropriate target framework version.

mengke2815 commented 1 week ago

I have the same problem,it donesn’t work

image

kdaek21 commented 1 week ago

To statically convert for .NET Core, I found the following. Example) Static conversion for net8.0

ikvmc -target:library -r:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.10\ref\net8.0\System.Runtime.dll" -runtime:"D:\Java\ikvm-jre8-net8.0\bin\IKVM.Runtime.dll" -nostdlib -main:[Class name including the package containing the main function] [classOrjar1] ... [classOrJarN]

I ended up finding what I wanted myself, so I'll close this issue.

kdaek21 commented 1 week ago

I have the same problem,it donesn’t work

image

I was adding information about net core, and you answered it again.. net core needs to be compiled properly with the -nostdlib option.

mengke2815 commented 1 week ago

thanks

mengke2815 commented 1 week ago

I have another problem,can you help me

image

kdaek21 commented 1 week ago

I have another problem,can you help me

image

net core requires more references than net472. Below is the compilation syntax that I tested with Tomcat. When compiling Tomcat...

System.Runtime.dll is required by default, and Systme.Console.dll, System.Threading.dll, and System.Threading.Thread.dll were additionally required.

ikvmc -target:library -r:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.10\ref\net8.0\System.Runtime.dll" -r:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.10\ref\net8.0\System.Console.dll" -r:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.10\ref\net8.0\System.Threading.dll" -r:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.10\ref\net8.0\System.Threading.Thread.dll" -runtime:"D:\Java\ikvm-jre8-net8.0\bin\IKVM.Runtime.dll" -recurse:"./lib" -nostdlib -main:"org.apache.catalina.startup.Bootstrap" bootstrap.jar tomcat-juli.jar

mengke2815 commented 1 week ago

I have another problem,can you help me image

net core requires more references than net472. Below is the compilation syntax that I tested with Tomcat. When compiling Tomcat...

System.Runtime.dll is required by default, and Systme.Console.dll, System.Threading.dll, and System.Threading.Thread.dll were additionally required.

ikvmc -target:library -r:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.10\ref\net8.0\System.Runtime.dll" -r:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.10\ref\net8.0\System.Console.dll" -r:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.10\ref\net8.0\System.Threading.dll" -r:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.10\ref\net8.0\System.Threading.Thread.dll" -runtime:"D:\Java\ikvm-jre8-net8.0\bin\IKVM.Runtime.dll" -recurse:"./lib" -nostdlib -main:"org.apache.catalina.startup.Bootstrap" bootstrap.jar tomcat-juli.jar

oh,i understand,thanks very much~!