Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/ikvm-fork.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'website/build/site/userguide/tutorial.html')
-rw-r--r--website/build/site/userguide/tutorial.html405
1 files changed, 405 insertions, 0 deletions
diff --git a/website/build/site/userguide/tutorial.html b/website/build/site/userguide/tutorial.html
new file mode 100644
index 00000000..d46b0807
--- /dev/null
+++ b/website/build/site/userguide/tutorial.html
@@ -0,0 +1,405 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>IKVM.NET Tutorial</title>
+<link type="text/css" href="../skin/page.css" rel="stylesheet">
+</head>
+<body text="#000000" bgcolor="#FFFFFF">
+<!--================= start Navigation Path ==================-->
+<table summary="navigation path" width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr>
+<td nowrap="nowrap" valign="middle" bgcolor="#CFDCED" height="20"><img height="1" width="5" alt="" src="../skin/images/spacer.gif" class="spacer"><!--===== breadcrumb trail (javascript-generated) ====--><font size="2" face="Arial, Helvetica, Sans-serif"><script src="../skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script></font></td>
+</tr>
+<tr>
+<td bgcolor="#4C6C8F" height="2"><img height="2" width="2" alt="" src="../skin/images/spacer.gif" class="spacer"></td>
+</tr>
+</table>
+<!--================= end Navigation Path ==================-->
+<!--================= start Banner ==================-->
+<table summary="header with logos" width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr>
+<!--================= start Group Logo ==================-->
+<td bgcolor="#294563"></td>
+<!--================= end Group Logo ==================-->
+<!--================= start Project Logo ==================--><td width="100%" align="center" bgcolor="#294563"><a href="http://www.ikvm.net/"><img border="0" class="logoImage" alt="IKVM.NET" src="../images/project.gif" title="Java on .NET"></a></td>
+<!--================= end Project Logo ==================-->
+<!--================= start Search ==================--><td valign="top" rowspan="2" bgcolor="#294563"></td>
+<!--================= start Search ==================--><td bgcolor="#294563"><img height="10" width="10" alt="" src="../skin/images/spacer.gif" class="spacer"></td>
+</tr>
+<tr>
+<td valign="bottom" bgcolor="#294563" colspan="2">
+<!--================= start Tabs ==================-->
+<div class="tab">
+<table summary="tab bar" border="0" cellpadding="0" cellspacing="0">
+<tr>
+<td width="6"><img alt="" height="8" width="6" src="../skin/images/spacer.gif"></td>
+</tr>
+</table>
+</div>
+<!--================= end Tabs ==================-->
+</td><td bgcolor="#294563"><img alt="" width="1" height="1" src="../skin/images/spacer.gif" class="spacer"></td>
+</tr>
+<tr>
+<td bgcolor="#4C6C8F" colspan="4"><img width="1" height="10" alt="" src="../skin/images/spacer.gif" class="spacer"></td>
+</tr>
+</table>
+<!--================= end Banner ==================-->
+<!--================= start Menu, NavBar, Content ==================-->
+<table summary="page content" bgcolor="#ffffff" width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr>
+<td valign="top">
+<table summary="menu" border="0" cellspacing="0" cellpadding="0">
+<tr>
+<!--================= start left top NavBar ==================-->
+<td rowspan="3" valign="top">
+<table summary="blue line" border="0" cellpadding="0" cellspacing="0">
+<tr>
+<td bgcolor="#294563"><img width="10" height="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td>
+</tr>
+<tr>
+<td bgcolor="#CFDCED"><font color="#4C6C8F" size="4" face="Arial, Helvetica, Sans-serif">&nbsp;</font></td>
+</tr>
+<tr>
+<td bgcolor="#294563"><img width="10" height="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td>
+</tr>
+</table>
+</td>
+<!--================= end left top NavBar ==================--><td bgcolor="#294563"><img width="1" height="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td><td valign="bottom" bgcolor="#4C6C8F"><img width="10" height="10" alt="" src="../skin/images/spacer.gif" class="spacer"></td><td nowrap="nowrap" valign="top" bgcolor="#4C6C8F">
+<!--================= start Menu items ==================-->
+<div class="menu">
+<ul>
+<li>
+<font color="#CFDCED">About</font>
+<ul>
+
+<li>
+<a href="../index.html" title="">Home</a>
+</li>
+
+<li>
+<a href="../download.html" title="">Download</a>
+</li>
+
+<li>
+<a href="../uses.html" title="">Uses</a>
+</li>
+
+<li>
+<a href="http://weblog.ikvm.net" title="">News</a>
+</li>
+
+<li>
+<a href="../faqdoc.html" title="">FAQ</a>
+</li>
+
+<li>
+<a href="../license.html" title="">License</a>
+</li>
+
+</ul>
+</li>
+<li>
+<font color="#CFDCED">User's Guide</font>
+<ul>
+
+<li>
+<a href="../userguide/intro.html">Introduction</a>
+</li>
+
+<li>
+<a href="../userguide/install.html" title="">Installation</a>
+</li>
+
+<li>
+<span class="sel"><font color="#ffcc00">Tutorial</font></span>
+</li>
+
+<li>
+<a href="../userguide/tools.html" title="">Tools Reference</a>
+</li>
+
+
+
+
+</ul>
+</li>
+<li>
+<font color="#CFDCED">Developer's Guide</font>
+<ul>
+
+<li>
+<a href="../devguide/intro.html" title="">Introduction</a>
+</li>
+
+<li>
+<a href="../devguide/concepts.html" title="">Concepts</a>
+</li>
+
+<li>
+<a href="../devguide/net2java.html" title="">Using Java Libraries</a>
+</li>
+
+<li>
+<a href="../devguide/java2net.html" title="">Developing in Java</a>
+</li>
+
+</ul>
+</li>
+<li>
+<font color="#CFDCED">Contributing</font>
+<ul>
+
+<li>
+<a href="http://sourceforge.net/mail/?group_id=69637">Mailing Lists</a>
+</li>
+
+<li>
+<a href="http://sourceforge.net/cvs/?group_id=69637">CVS Repository</a>
+</li>
+
+</ul>
+</li>
+</ul>
+</div>
+<!--================= end Menu items ==================-->
+</td><td valign="bottom" bgcolor="#4C6C8F"><img width="10" height="10" alt="" src="../skin/images/spacer.gif" class="spacer"></td><td bgcolor="#294563"><img width="1" height="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td>
+</tr>
+<tr>
+<td valign="bottom" align="left" colspan="2" rowspan="2" bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="../skin/images/menu-left.gif"></td><td bgcolor="#4C6C8F"><img height="10" width="10" alt="" src="../skin/images/spacer.gif" class="spacer"></td><td valign="bottom" align="right" colspan="2" rowspan="2" bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="../skin/images/menu-right.gif"></td>
+</tr>
+<tr>
+<td height="1" bgcolor="#294563"><img width="1" height="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td>
+</tr>
+</table>
+</td><td valign="top" width="100%">
+<table summary="content" width="100%" border="0" cellpadding="0" cellspacing="0">
+<!--================= start middle NavBar ==================-->
+<tr>
+<td colspan="4" bgcolor="#294563"><img width="10" height="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td>
+</tr>
+<tr>
+<td align="left" width="10" bgcolor="#CFDCED"><img width="10" height="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td><td align="left" width="50%" bgcolor="#CFDCED"><font color="#4C6C8F" size="3" face="Arial, Helvetica, Sans-serif">
+ &nbsp;
+
+ </font><img width="10" height="8" alt="" src="../skin/images/spacer.gif" class="spacer"></td><td align="right" width="50%" bgcolor="#CFDCED"><font color="#4C6C8F" size="3" face="Arial, Helvetica, Sans-serif">
+ &nbsp;
+
+ </font><img width="10" height="8" alt="" src="../skin/images/spacer.gif" class="spacer"></td><td width="10" bgcolor="#CFDCED"><img width="10" height="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td>
+</tr>
+<tr>
+<td colspan="4" bgcolor="#294563"><img width="10" height="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td>
+</tr>
+<!--================= end middle NavBar ==================-->
+<!--================= start Content==================-->
+<tr>
+<td align="left" width="10"><img width="10" height="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td><td colspan="2" align="left" width="100%">
+<div class="content">
+<table class="title" summary="">
+<tr>
+<td valign="middle">
+<h1>IKVM.NET Tutorial</h1>
+</td>
+</tr>
+</table>
+<ul class="minitoc">
+<li>
+<a href="#Setup+your+Environment">Setup your Environment</a>
+</li>
+<li>
+<a href="#Run+a+Java+Application+Dynamically">Run a Java Application Dynamically</a>
+</li>
+<li>
+<a href="#Convert+a+Java+Application+to+.NET">Convert a Java Application to .NET</a>
+</li>
+<li>
+<a href="#Develop+a+.NET+Application+in+Java">Develop a .NET Application in Java</a>
+</li>
+</ul>
+
+<a name="N10012"></a><a name="Setup+your+Environment"></a>
+<h3>Setup your Environment</h3>
+<div style="margin-left: 0 ; border: 2px">
+<p>This tutorial includes information for both the Windows and Linux platforms. It assumes that
+ Windows users will be using the .NET SDK, and Linux users will be using the Mono SDK. </p>
+<p>This tutorial references files in the samples distribution available on the <a href="../download.html">download page</a>.
+ Before you begin, prepare your environment by adding the following to your PATH environment variable:</p>
+<ul>
+
+<li>The directory containing the IKVM executables</li>
+
+<li>The directory containing the C# compiler (Windows: csc / Mono: mcs). On Windows, this is typically
+ C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322.</li>
+
+<li>The directory containing a Java compiler (javac or jikes)</li>
+
+</ul>
+</div>
+
+
+<a name="N1002F"></a><a name="Run+a+Java+Application+Dynamically"></a>
+<h3>Run a Java Application Dynamically</h3>
+<div style="margin-left: 0 ; border: 2px">
+<p>IKVM.NET includes a Java Virtual Machine implented in C#. To try it out, navigate to
+ <em>IKVMROOT</em>\samples\hello and compile the sample application:</p>
+<div class="pre">
+<span class="codefrag"> javac Hello
+ jar cfm hello.jar manifest.mf Hello.class</span>
+</div>
+<p>Now, to run the application using the IKVM Virtual Machine, enter the following:</p>
+<div class="pre">
+<span class="codefrag"> ikvm Hello</span>
+</div>
+<p>This command starts the virtual machine, which searches for a
+ file named Hello.class. When it finds it, it loads it and executes the bytecodes dynamically.
+ You should be prompted to enter your name, and see a brief greeting.</p>
+<p>If you experience problems, check the following:</p>
+<ul>
+
+<li>Check your capitalization: ikvm, like java, requires you to capitalize class names correctly.</li>
+
+<li>If ikvm reports a ClassNotFoundException, check whether the CLASSPATH environment variable is set.
+ If so, try clearing the CLASSPATH or adding the current directory to it so ikvm can find the class in the current directory.</li>
+
+</ul>
+<p>You can also execute Java applications in a jar file. Try it out:</p>
+<div class="pre">
+<span class="codefrag"> ikvm -jar hello.jar</span>
+</div>
+<p>See the <a href="../userguide/ikvm.html">ikvm reference</a> for more information about ikvm command line options.</p>
+</div>
+
+
+<a name="N1006A"></a><a name="Convert+a+Java+Application+to+.NET"></a>
+<h3>Convert a Java Application to .NET</h3>
+<div style="margin-left: 0 ; border: 2px">
+<p>IKVM.NET includes <a href="../userguide/ikvmc.html">ikvmc</a>, a utility that converts
+ Java .jar files to .NET .dll libraries and .exe applications. In this section, you'll convert a Java application to a .NET
+ .exe.</p>
+<p>Navigate to <em>IKVMROOT</em>\samples\hello and enter the following:</p>
+<div class="pre">
+<span class="codefrag"> ikvmc hello.jar</span>
+</div>
+<div class="frame note">
+<div class="label">Note</div>
+<div class="content">If you're using Mono, you will have to tell ikvmc where to find the GNU Classpath dll. Try the following,
+ substituting the location of IKVM.GNU.Classpath.dll on your system if necessary:<br>
+
+<br>
+
+<span class="codefrag">ikvmc -reference:/usr/lib/IKVM.GNU.Classpath.dll hello.jar</span>
+
+</div>
+</div>
+<p>After the command completes, you should find a hello.exe file in the current directory. To execute it:</p>
+<ul>
+
+<li>
+<strong>Windows / .NET Framework:</strong>
+
+<p>Try running hello.exe. If you get a FileNotFound exception when the .NET runtime attempts to load the referenced
+ IKVM.GNU.Classpath.dll, remember that the .NET framework expects to find referenced dll's in the current
+ directory or in the Global Assembly Cache. Either <a href="../userguide/install.html">install the dll's in the
+ Global Assembly Cache</a>, or copy them to the current directory.</p>
+
+</li>
+
+<li>
+<strong>Linux / Mono:</strong>
+
+<p>Run it using the following command:</p>
+
+<div class="pre">
+<span class="codefrag"> mono hello.exe</span>
+</div>
+
+</li>
+
+</ul>
+</div>
+
+
+<a name="tutorial_java2net"></a>
+ <a name="N100B1"></a><a name="Develop+a+.NET+Application+in+Java"></a>
+<h3>Develop a .NET Application in Java</h3>
+<div style="margin-left: 0 ; border: 2px">
+<p>In this section, you will learn the steps needed to develop .NET applications in Java. </p>
+<p>To begin, open a command window and navigate to <em>IKVMROOT</em>\samples\usenetapi.
+ Take a look at ShowDir.java -- this is a Java application that uses the .NET API to display a list of files
+ in the current directory. Notice the imports at the top -- the package names begin with <span class="codefrag">cli.*</span>. These are not
+ packages in the Java API; rather, they are "pseudo" packages that map to .NET namespaces.
+ For more information on this, see the <a href="../devguide/java2net.html">Developer's Guide</a>.</p>
+<p>
+<strong>Step 1: Generate Java stubs</strong>
+</p>
+<p>IKVM does not come with a Java compiler, so we will compile ShowDir using a standard Java compiler.
+ Since Java compilers can only compile applications that use Java API's, not .NET API's, we have to fool the
+ Java compiler into believing that there is really a Java package named cli.System.IO. The
+ <a href="../userguide/ikvmstub.html">ikvmstub</a> application
+ helps us do this. It generates Java jar files from .NET dll's. The jar files generated by ikvmstub contain Java classes
+ and interfaces that correspond to .NET classes, but don't contain any real code. They contain just enough to satisfy
+ the Java compiler, and allow it to type check the Java application.</p>
+<p>Type the following:</p>
+<div class="pre">
+<span class="codefrag"> ikvmstub mscorlib.dll</span>
+</div>
+<p>Note: On a Linux Mono installation, you will have to type the full pathname to mscorlib.dll, like this:</p>
+<div class="pre">
+<span class="codefrag"> ikvmstub /usr/lib/mscorlib.dll</span>
+</div>
+<p>After the command completes, you should find a file named mscorlib.jar in the current directory.</p>
+<p>
+<strong>Step 2: Compile the Java source code</strong>
+</p>
+<p>Now, we'll compile the Java source code. If you're using javac, type the following:</p>
+<div class="pre">
+<span class="codefrag"> javac -classpath mscorlib.jar ShowDir.java</span>
+</div>
+<p>(Substitute <span class="codefrag">jikes</span> for <span class="codefrag">javac</span> if you're using that tool.)</p>
+<p>After the command completes, you should find ShowDir.class in the current directory. </p>
+<p>
+<strong>Step 3: Generate a .NET executable</strong>
+</p>
+<p>Now, we'll convert the Java class file to a .NET application. Type the following:</p>
+<div class="pre">
+<span class="codefrag"> ikvmc ShowDir.class</span>
+</div>
+<p>Note: On a Linux Mono installation, you will have to add a -reference option, like this:</p>
+<div class="pre">
+<span class="codefrag"> ikvmc -reference:/usr/lib/IKVM.GNU.Classpath.dll ShowDir.class</span>
+</div>
+<p>After the command completes, you should find ShowDir.exe in the current directory. You should be able to
+ execute it successfully. (On Windows .NET, remember to copy the IKVM dll's to the current directory.)</p>
+</div>
+
+
+
+
+<div class="attribution">by&nbsp;Stephen Schaub</div>
+</div>
+</td><td width="10"><img width="10" height="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td>
+</tr>
+<!--================= end Content==================-->
+</table>
+</td>
+</tr>
+</table>
+<!--================= end Menu, NavBar, Content ==================-->
+<!--================= start Footer ==================-->
+<table summary="footer" cellspacing="0" cellpadding="0" width="100%" border="0">
+<tr>
+<td colspan="2" height="1" bgcolor="#4C6C8F"><img height="1" width="1" alt="" src="../skin/images/spacer.gif" class="spacer"><a href="../skin/images/label.gif"></a><a href="../skin/images/page.gif"></a><a href="../skin/images/chapter.gif"></a><a href="../skin/images/chapter_open.gif"></a><a href="../skin/images/current.gif"></a><a href="/favicon.ico"></a></td>
+</tr>
+<tr>
+<td colspan="2" bgcolor="#CFDCED" class="copyright" align="center"><font size="2" face="Arial, Helvetica, Sans-Serif">Copyright &copy;
+ 2004&nbsp;Jeroen Frijters All rights reserved.<script type="text/javascript" language="JavaScript"><!--
+ document.write(" - "+"Last Published: " + document.lastModified);
+ // --></script></font></td>
+</tr>
+<tr>
+<td colspan="2" align="left" bgcolor="#CFDCED" class="logos"></td>
+</tr>
+</table>
+<!--================= end Footer ==================-->
+</body>
+</html>