blob: 34bdf1f1818c5d72b8789af22ba4425af4efc46f [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<title>1.4 - First Steps &mdash; Apache MINA</title>
<link href="/assets/css/common.css" rel="stylesheet" type="text/css"/>
<link href="/assets/css/mina.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<script src="https://www.apachecon.com/event-images/snippet.js"></script>
<div id="container">
<div id="header">
<div id="subProjectsNavBar">
<a href="/">
Apache MINA Project
</a>
&nbsp;|&nbsp;
<a href="/mina-project/">
<strong>MINA</strong>
</a>
&nbsp;|&nbsp;
<a href="/asyncweb-project/">
AsyncWeb
</a>
&nbsp;|&nbsp;
<a href="/ftpserver-project/">
FtpServer
</a>
&nbsp;|&nbsp;
<a href="/sshd-project/">
SSHD
</a>
&nbsp;|&nbsp;
<a href="/vysper-project/">
Vysper
</a>
</div>
</div>
<div id="content">
<div id="leftColumn">
<div id="navigation">
<a class="acevent" data-format="wide" data-width="170"></a>
<h5>Social Networks</h5>
<ul>
<li><a href="https://fosstodon.org/@apachemina">Apache MINA Mastodon</a></li>
</ul>
<h5>Latest Downloads</h5>
<ul>
<li><a href="/mina-project/downloads_2_0.html">Mina 2.0.25</a></li>
<li><a href="/mina-project/downloads_2_1.html">Mina 2.1.8</a></li>
<li><a href="/mina-project/downloads_2_2.html">Mina 2.2.3</a></li>
<li><a href="/mina-project/downloads_old.html">Mina old versions</a></li>
</ul>
<h5>Documentation</h5>
<ul>
<li><a href="/mina-project/documentation.html" class="external-link" rel="nofollow">Base documentation</a></li>
<li><a href="/mina-project/userguide/user-guide-toc.html" class="external-link" rel="nofollow">User guide</a></li>
<li><a href="/mina-project/2.2-vs-2.1.html" class="external-link" rel="nofollow">2.2 vs 2.1</a></li>
<li><a href="/mina-project/2.1-vs-2.0.html" class="external-link" rel="nofollow">2.1 vs 2.0</a></li>
<li><a href="/mina-project/features.html" class="external-link" rel="nofollow">Features</a></li>
<li><a href="/mina-project/road-map.html" class="external-link" rel="nofollow">Road Map</a></li>
<li><a href="/mina-project/quick-start-guide.html" class="external-link" rel="nofollow">Quick Start Guide</a></li>
<li><a href="/mina-project/faq.html" class="external-link" rel="nofollow">FAQ</a></li>
</ul>
<h5>Resources</h5>
<ul>
<li><a href="/mina-project/mailing-lists.html" class="external-link" rel="nofollow">Mailing lists &amp; IRC</a></li>
<li><a href="/mina-project/issue-tracking.html" class="external-link" rel="nofollow">Issue tracking</a></li>
<li><a href="/mina-project/sources.html" class="external-link" rel="nofollow">Sources</a></li>
<li><a href="/mina-project/gen-docs/latest-2.0/apidocs/index.html" class="external-link" rel="nofollow">API Javadoc 2.0.25</a></li>
<li><a href="/mina-project/gen-docs/latest-2.1/apidocs/index.html" class="external-link" rel="nofollow">API Javadoc 2.1.8</a></li>
<li><a href="/mina-project/gen-docs/latest-2.2/apidocs/index.html" class="external-link" rel="nofollow">API Javadoc 2.2.3</a></li>
<li><a href="/mina-project/gen-docs/latest-2.0/xref/index.html" class="external-link" rel="nofollow">API xref 2.0.25</a></li>
<li><a href="/mina-project/gen-docs/latest-2.1/xref/index.html" class="external-link" rel="nofollow">API xref 2.1.8</a></li>
<li><a href="/mina-project/gen-docs/latest-2.2/xref/index.html" class="external-link" rel="nofollow">API xref 2.2.3</a></li>
<li><a href="/mina-project/performances.html" class="external-link" rel="nofollow">Performances</a></li>
<li><a href="/mina-project/testimonials.html" class="external-link" rel="nofollow">Testimonials</a></li>
<li><a href="/mina-project/conferences.html" class="external-link" rel="nofollow">Conferences</a></li>
<li><a href="/mina-project/developer-guide.html" class="external-link" rel="nofollow">Developers Guide</a></li>
<li><a href="/mina-project/related-projects.html" class="external-link" rel="nofollow">Related Projects</a></li>
<li><a href="https://people.apache.org/~vgritsenko/stats/projects/mina.html" class="external-link" rel="nofollow">Statistics</a></li>
</ul>
<h5>Community</h5>
<ul>
<li><a href="https://www.apache.org/foundation/contributing.html" class="external-link" rel="nofollow">Contributing</a></li>
<li><a href="/contributors.html" class="external-link" rel="nofollow">Team</a></li>
<li><a href="/special-thanks.html" class="external-link" rel="nofollow">Special Thanks</a></li>
<li><a href="https://www.apache.org/security/" class="external-link" rel="nofollow">Security</a></li>
</ul>
<h5>About Apache</h5>
<ul>
<li><a href="https://www.apache.org" class="external-link" rel="nofollow">Apache main site</a></li>
<li><a href="https://www.apache.org/licenses/" class="external-link" rel="nofollow">License</a></li>
<li><a href="https://www.apache.org/foundation/sponsorship.html" title="The ASF sponsorship program" class="external-link" rel="nofollow">Sponsorship program</a></li>
<li><a href="https://www.apache.org/foundation/thanks.html" class="external-link" rel="nofollow">Thanks</a></li>
</ul>
<h3><a name="Navigation-Upcoming"></a>Upcoming</h3>
<ul>
<li>No event</li>
</ul>
</div>
</div>
<div id="rightColumn">
<div class="nav">
<div class="nav_prev">
<a href="ch1.3-features.html">1.3 - Features</a>
</div>
<div class="nav_up">
<a href="ch1-getting-started.html">Chapter 1 - Getting Started</a>
</div>
<div class="nav_next">
<a href="ch1.5-summary.html">1.5 - Summary</a>
</div>
<div class="clearfix"></div>
</div>
<h1 id="first-steps">First Steps</h1>
<p>We will show you how easy it is to use MINA, running a very simple example provided with the <strong>MINA</strong> package.</p>
<p>The first thing you have to do is to setup your environment when you want to use <strong>MINA</strong> in your application. We will describe what you need to install and how to run a <strong>MINA</strong> program. Nothing fancy, just a first taste of <strong>MINA</strong>&hellip;</p>
<h2 id="download">Download</h2>
<p>First, you have to download the latest <strong>MINA</strong> release from <a href="../../downloads_2_0.html">MINA 2.0 Downloads Section</a> or <a href="../../downloads_2_1.html">MINA 2.1 Downloads Section</a>. Just take the latest version, unless you have very good reasons not to do so&hellip;</p>
<p>Generally speaking, if you are going to use <strong>Maven</strong> to build your project, you won&rsquo;t even have to download anything, as soon as you will depend on a repository which already contains the <strong>MINA</strong> libraries : you just tell your <strong>Maven</strong> poms that you want to use the <strong>MINA</strong> jars you need.</p>
<h2 id="whats-inside">What&rsquo;s inside</h2>
<p>After the download is complete, extract the content of <em>tar.gz</em> or <em>zip</em> file to local hard drive. The downloaded compressed file has following contents</p>
<p>On UNIX system, type :</p>
<pre><code>$ tar xzpf apache-mina-2.0.7-tar.gz
</code></pre>
<p>In the <em>apache-mina-2.0.7</em> directory, you will get :</p>
<pre><code> |
+- dist
+- docs
+- lib
+- src
+- LICENSE.txt
+- LICENSE.jzlib.txt
+- LICENSE.ognl.txt
+- LICENSE.slf4j.txt
+- LICENSE.springframework.txt
+- NOTICE.txt
</code></pre>
<h2 id="content-details">Content Details</h2>
<ul>
<li><em>dist</em> - Contains jars for the <strong>MINA</strong> library code</li>
<li><em>docs</em> - Contains API docs and Code xrefs</li>
<li><em>lib</em> - Contains all needed jars for all the libraries needed for using <strong>MINA</strong></li>
</ul>
<p>Additional to these, the base directory has couple of license and notice files</p>
<h1 id="running-your-first-mina-program">Running your first MINA program</h1>
<p>Well, we have downloaded the release, let&rsquo;s run our first <strong>MINA</strong> example, shipped with the release.</p>
<p>Put the following jars in the classpath</p>
<ul>
<li>mina-core-2.0.7.jar</li>
<li>mina-example-2.0.7.jar</li>
<li>slf4j-api-1.6.6.jar</li>
<li>slf4j-log4j12-1.6.6.jar</li>
<li>log4j-1.2.17.jar</li>
</ul>
<div class="tip" markdown="1">
<strong>Logging Tip</string>
<ul>
<li>Log4J 1.2 users: slf4j-api.jar, slf4j-log4j12.jar, and Log4J 1.2.x</li>
<li>Log4J 1.3 users: slf4j-api.jar, slf4j-log4j13.jar, and Log4J 1.3.x</li>
<li>java.util.logging users: slf4j-api.jar and slf4j-jdk14.jar</li>
</ul>
<p><strong>IMPORTANT:<strong> Please make sure you are using the right <em>slf4j-*.jar</em> that matches to your logging framework.
For instance, <em>slf4j-log4j12.jar</em> and <em>log4j-1.3.x.jar</em> can not be used together, and will malfunction.
If you don&rsquo;t need a logging framework you can use <em>slf4j-nop.jar</em> for no logging or <em>slf4j-simple.jar</em> for
very basic logging.</p>
</div>
<p>On the command prompt, issue the following command :</p>
<pre><code>$ java org.apache.mina.example.gettingstarted.timeserver.MinaTimeServer
</code></pre>
<p>This shall start the server. Now telnet and see the program in action</p>
<p>Issue following command to telnet</p>
<pre><code>telnet 127.0.0.1 9123
</code></pre>
<p>Well, we have run our first <strong>MINA</strong> program. Please try other sample programs shipped with <strong>MINA</strong> as examples.</p>
<div class="nav">
<div class="nav_prev">
<a href="ch1.3-features.html">1.3 - Features</a>
</div>
<div class="nav_up">
<a href="ch1-getting-started.html">Chapter 1 - Getting Started</a>
</div>
<div class="nav_next">
<a href="ch1.5-summary.html">1.5 - Summary</a>
</div>
<div class="clearfix"></div>
</div>
</div>
<div id="endContent"></div>
</div>
<div id="footer">
&copy; 2003-2024, <a href="https://www.apache.org">The Apache Software Foundation</a> - <a href="https://privacy.apache.org/policies/privacy-policy-public.html">Privacy Policy</a><br />
Apache MINA, MINA, Apache Vysper, Vysper, Apache SSHd, SSHd, Apache FtpServer, FtpServer, Apache AsyncWeb, AsyncWeb,
Apache, the Apache feather logo, and the Apache Mina project logos are trademarks of The Apache Software Foundation.
</div>
</div>
</body>
</html>