# IKVM.NET Bytecode Compiler (ikvmc.exe)
The ikvmc tool converts Java bytecode to .NET dll's and exe's. Usage Options Notes Examples ### Usage
ikvmc [ options ] classOrJarfile [ classOrJarfile ... ]
options See below. classOrJarfile Name of a Java .class or .jar file. May contain wildcards (*.class). ### Options
Option | Description
--- | ---
-out:outputfile | Specifies the name of the output file. Should have a .dll extension (if -target is library) or an .exe extension (if -target is exe or winexe). In most cases, if you omit this option, ikvmc will choose an output name based on the -target and the name of the input files. However, if you specify input files using wildcards, you must use this option to specify the output file.
-assembly:assembly-name | Specifies the name of the generated assembly. If omitted, the assembly name is (usually) the output filename.
-target:target-type | Specifies whether to generate an .exe or .dll. target-type is one of exe - generates an executable that runs in a Windows command window winexe - generates an .exe for GUI applications library - generates a .dll module - generates a .netmodule On Linux, there is no difference between exe and winexe.
-keyfile:keyfilename | Uses keyfilename to sign the resulting assembly.
-version:M.m.b.r | Specifies the assembly version.
-main:classname | Specifies the name of the class containing the main method. If omitted and the -target is exe or winexe, ikvmc searches for a qualifying main method and reports if it finds one.
-reference:library-filespec | If your Java code uses .NET API's, specify the dll's using this option. This option can appear more than once if more than one library is referenced. Wildcards are permitted (e.g. c:\libs\*.dll).
-recurse:filespec | Processes all files matching filespec in and under the directory specified by filespec. Example: -recurse:*.class
-nojni | Do not generate JNI stub for native methods
-resource:name=path | Includes path as a Java resource named name
-exclude:filename | filename is a file containing a list of classes to exclude
-debug | Generates debugging information in the output. Note that this is only helpful if the .class files contain debug information (compiled with the javac -g option).
-srcpath:path | Specifies the location of source code. Use with -debug. The package of the class is appended to the specified path to locate the source code for the class.
-Xtrace:name | Displays all tracepoints with name
-Xmethodtrace:methodname | Builds method trace into the specified output method.
### Notes The ikvmc tool generates .NET assemblies from Java class files and jar files. It converts the Java bytecodes in the input files to .NET CIL. Use it to produce .NET executables (-target:exe or -target:winexe) .NET libraries (-target:library) .NET modules (-target:module) Java applications often consist of a collection of jar files. ikvmc can process several input jar files (and class files) and produce a single .NET executable or library. For example, an application consisting of main.jar, lib1.jar, and lib2.jar can be converted to a single main.exe. When processing multiple input jar files that contain duplicate classes / resources, ikvmc will use the first class / resource it encounters, and ignore duplicates encountered in jars that appear later on the command line. It will produce a warning in this case. Thus, order of jar files can be significant. Note When converting a Java application with ikvmc, for best results, list the jars on the ikvmc command line in the same order that they appear in the Java application's classpath. ### Examples ikvmc myProg.jar Scans myprog.jar for a main method. If found, an .exe is produced; otherwise, a .dll is generated. ikvmc -out:myapp.exe -main:org.anywhere.Main -recurse:bin\*.class lib\mylib.jar Processes all .class files in and under the bin directory, and mylib.jar in the lib directory. Generates an executable named myapp.exe using the class org.anywhere.Main as the main method. |

Send feedback about this page to webmaster@ikvm.net Copyright © 2008 Jeroen Frijters All rights reserved.