IKVM.NET_第七篇_用户指南_工具ikvmc.exe

IKVM.NET的ikvmc工具将Java字节码转换成.NET dll文件或是exe文件。本文介绍内容如下:
1) 用法
2) 选项
3) 备注
4) 例子
+++ 用法
ikvmc [ options ] classOrJarfile [ classOrJarfile ... ]
options具体在下面介绍。
classOrJarfile是Java .class文件或jar文件,可以包含通配符(*.class)。
+++ 选项
1) -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.
2) -assembly:assembly-name
Specifies the name of the generated assembly. If omitted, the assembly name is (usually) the output filename.
3) -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.
4) -keyfile :keyfilename  Uses keyfilename to sign the resulting assembly. 
5) -version:M.m.b.r  Specifies the assembly version. 
6) -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.
7) -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). 
8) -recurse:filespec  Processes all files matching filespec in and under the directory specified by filespec. Example: -recurse:*.class 
9) -nojni  Do not generate JNI stub for native methods 
10) -resource:name=path  Includes path as a Java resource named name 
11) -exclude:filename  filename is a file containing a list of classes to exclude 
12) -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). 
13) -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. 
14) -Xtrace:name  Displays all tracepoints with name 
15) -Xmethodtrace:methodname  Builds method trace into the specified output method.
+++ 备注
ikvmc工具可以从Java字节码文件生成.NET装配。Ikvmc可以把输入文件中的Java字节码转换成.NET公共中间语言(CIL),用它可以生成如下.NET文件:
1) 利用“-target:exe”或“-target:winexe”选项可以生成.NET可执行程序;
2) 利用“-target:library”选项可以生成.NET库文件;
3) 利用“-target:module”选项可以生成.NET 模块。
Java应用程序通常是jar文件的集合。ikvmc应用程序能够处理许多输入的jar文件(和字节码文件),并且生成一个.NET可执行程序或库文件。假如一个由main.jar、lib1.jar和lib2.jar文件组成的Java应用程序可以被转换成一个.NET main.exe文件。当处理多个输入的jar文件时,ikvmc将使用它遇到的第一个字节码文件或资源文件,而忽略之后遇到的文件。因此,jar文件的顺序是有意义的。
+++ 备注
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.
当用ikvmc转换java应用程序时,在ikvmc命令中列出的jar文件的顺序与Java应用程序的classpath出现的顺序相同。
+++ 例子
命令“ikvmc myProg.jar”,ikvmc扫描myProg.jar,如果找到main方法,就产生一个.exe文件,否则,就产生一个.dll文件。
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.
上面的命令行,处理/bin中和它子目录中所有的.class文件和.jar文件,以及lib目录下的jar文件,并且把“org.anywhere.Main”作为main方法,生成一个名为“myapp.exe”可执行程序。

 

IKVM.NET Bytecode Compiler (ikvmc.exe)
The ikvmc tool converts Java bytecode to .NET dll's and exe's.
1) Usage
2) Options
3) Notes
4) Examples
+++ Usage
ikvmc [ options ] classOrJarfile [ classOrJarfile ... ]
options
See below.
classOrJarfile
Name of a Java .class or .jar file. May contain wildcards (*.class).
+++ Options
1) -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.
2) -assembly:assembly-name
Specifies the name of the generated assembly. If omitted, the assembly name is (usually) the output filename.
3) -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.
4) -keyfile :keyfilename  Uses keyfilename to sign the resulting assembly. 
5) -version:M.m.b.r  Specifies the assembly version. 
6) -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.
7) -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). 
8) -recurse:filespec  Processes all files matching filespec in and under the directory specified by filespec. Example: -recurse:*.class 
9) -nojni  Do not generate JNI stub for native methods 
10) -resource:name=path  Includes path as a Java resource named name 
11) -exclude:filename  filename is a file containing a list of classes to exclude 
12) -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). 
13) -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. 
14) -Xtrace:name  Displays all tracepoints with name 
15) -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
1) .NET executables (-target:exe or -target:winexe)
2) .NET libraries (-target:library)
3) .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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值