Professional Documents
Culture Documents
FROM .NET
Prepared By :Bar nalz
Date
: 03/07/2012
www.innovile.com
Disclaimer: This document is furnished by Innovile Telecommunications Ltd. without any claims,
warranties or indemnifications.
Improvements and changes in this document due to typographical errors, inaccuracy in current
information, or improvements to programs and/or equipment may be made by Innovile
Telecommunications Ltd. at any time without any notice(s). These changes will, however, be
incorporated into new revisions of this manual.
No part of this publication may be reproduced, transmitted, stored in a retrieval system, nor translated
into any human or computer language, in any form or by any means, electronic, mechanical, magnetic,
optical, manual or otherwise, without the prior written permission of the copyrighted owner, Innovile
Telecommunications Ltd.
Company Information
Support Contacts
E-Mail : support@innovile.com
Phone : 90-232-2820265
Fax
: 90-232-2820109
Web
: www.innovile.com
Options
Option
Description
-out:outputfile
-assembly:assembly-name
-target:target-type
-version:M.m.b.r
-main:classname
-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).
Form ID: INN-F-002-REV00_08.10.2010
-recurse:filespec
-nojni
-resource:name=path
-exclude:filename
-debug
-srcpath:path
-Xtrace:name
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.
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.
Example EnumParser
1)
}
static void ThreadGroup2()
{
ParserInfo pr = new ParserInfo();
pr.setBackupCompressionFlag(false);
pr.setInputDirectory("C:\\Users\\nnobarisi\\Desktop\\ENUMINPUTS2\\input");
pr.setOutputDirectory("C:\\Users\\nnobarisi\\Desktop\\ENUMINPUTS2\\output");
pr.setBackupDirectory("C:\\Users\\nnobarisi\\Desktop\\ENUMINPUTS2\\backup");
pr.setTemplateDirectory("C:\\Users\\nnobarisi\\Desktop\\ENUMINPUTS2\\conf");
pr.setLogDirectory("C:\\Users\\nnobarisi\\Desktop\\ENUMINPUTS2\\log");
pr.setTempDirectory("C:\\Users\\nnobarisi\\Desktop\\ENUMINPUTS2\\temp");
pr.setErrorDirectory("C:\\Users\\nnobarisi\\Desktop\\ENUMINPUTS2\\error");
pr.setDelimeter(",");
pr.setPlatform("W");
pr.setParserVersion("MSC");
pr.setInstanceId(1);
pr.setLowerLimit(0);
pr.setUpperLimit(1000000);
pr.setType("ENUM");
pr.setDataInterval(15);
pr.setMaxThreads(10);
pr.setLogLevel(1);
pr.setBackupAfterParse(true);
pr.setInputFileMask("*");
pr.setOutputHasHeader(true);
pr.setFilenameAsColumn(false);
Console.WriteLine(pr);
AssignJob EnumParser = new AssignJob(pr);
//EnumParser.PrintConsole();
if (EnumParser.checkMaskValidity())
{
if (EnumParser.setValidFileList())
{
EnumParser.run();
}
else
{
jar2ikvmc
Summary
The tool helps converting big bundles of Java jar files to .NET dlls using IKVM.NET.
Jar2ikvmc uses JarAnalyser to detect dependencies between jar files and then generates command-line
script for ikvmc.exe.
Example
Here is sample results of program running using jar files for JFreeChart:
Generated Script
ikvmc swtgraphics2d.jar -target:library
ikvmc servlet.jar -target:library
ikvmc junit.jar -target:library
ikvmc jcommon-1.0.10.jar -target:library
ikvmc gnujaxp.jar -target:library
ikvmc jfreechart-1.0.6.jar -target:library -r:jcommon-1.0.10.dll -r:servlet.dll r:gnujaxp.dll
ikvmc jfreechart-1.0.6-swt.jar -target:library -r:jfreechart-1.0.6.dll -r:jcommon1.0.10.dll
ikvmc jfreechart-1.0.6-experimental.jar -target:library -r:jfreechart-1.0.6.dll r:jcommon-1.0.10.dll
ikvmc itext-2.0.2.jar -target:library -r:gnujaxp.dll
Dependencies
Example:
.NET/C# to Java
// create bridge, with default setup
// it will lookup jni4net.j.jar next to jni4net.n.dll
Bridge.CreateJVM(new BridgeSetup(){Verbose=true});
// here you go!
java.lang.System.@out.println("Hello Java world!");
// OK, simple hello is boring, let's play with Java properties
// they are Hashtable realy
Properties javaSystemProperties = java.lang.System.getProperties();
// let's enumerate all keys.
// We use Adapt helper to convert enumeration from java o .NET
foreach (java.lang.String key in
Adapt.Enumeration(javaSystemProperties.keys()))
{
java.lang.System.@out.print(key);
Java to .NET