<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jimmy&#039;s Blog</title>
	<atom:link href="http://jimmod.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://jimmod.com/blog</link>
	<description>My name is Jimmy, and this is my story... ;)</description>
	<lastBuildDate>Sat, 05 Jan 2013 16:23:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Android Application &#8211; Spy Camera OS (Open Source)</title>
		<link>http://jimmod.com/blog/2013/01/android-application-spy-camera-os-open-source/</link>
		<comments>http://jimmod.com/blog/2013/01/android-application-spy-camera-os-open-source/#comments</comments>
		<pubDate>Sat, 05 Jan 2013 16:23:35 +0000</pubDate>
		<dc:creator>jimmy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[camera]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[halim]]></category>
		<category><![CDATA[jimmy]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[photography]]></category>

		<guid isPermaLink="false">http://jimmod.com/blog/?p=288</guid>
		<description><![CDATA[It&#8217;s been a while I create new post.
This time I want to promote my android application :

Spy Camera OS (Open Source)
Everyone at one time will want to capture image without anyone notice it.
It&#8217;s an open source project which make me learn deeper about what I can do with camera in android and various device compatibility [...]


Related posts:<ol><li><a href='http://jimmod.com/blog/2012/07/jimmys-blog-adding-admobs-ads-to-android-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Adding AdMob&#8217;s ads to Android Application'>Jimmy&#8217;s Blog &#8211; Adding AdMob&#8217;s ads to Android Application</a></li><li><a href='http://jimmod.com/blog/2011/10/android-market-error-on-downloading-error-downloading-there-is-insufficient-space-on-the-device/' rel='bookmark' title='Permanent Link: Android Market error on downloading (Error Downloading. There is insufficient space on the device.)'>Android Market error on downloading (Error Downloading. There is insufficient space on the device.)</a></li><li><a href='http://jimmod.com/blog/2012/07/jimmys-blog-ab-slide-puzzle-for-android/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; AB Slide Puzzle for Android'>Jimmy&#8217;s Blog &#8211; AB Slide Puzzle for Android</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div id="attachment_289" class="wp-caption aligncenter" style="width: 310px"><a href="http://jimmod.com/blog/wp-content/uploads/2013/01/feature.png"><img class="size-medium wp-image-289" title="Spy Camera OS (Open Source) Banner" src="http://jimmod.com/blog/wp-content/uploads/2013/01/feature-300x146.png" alt="Spy Camera OS (Open Source) Banner" width="300" height="146" /></a><p class="wp-caption-text">Spy Camera OS (Open Source) Banner</p></div>
<p>It&#8217;s been a while I create new post.</p>
<p style="text-align: left;">This time I want to promote my android application :<br />
<strong></strong></p>
<p style="text-align: center;"><strong>Spy Camera OS (Open Source)</strong><br />
<em>Everyone at one time will want to capture image without anyone notice it.</em></p>
<p>It&#8217;s an open source project which make me learn deeper about what I can do with camera in android and various device compatibility issues.<br />
I&#8217;m thinking to write related Android camera utilization related to this application.</p>
<p>You can download the application at: <a href="https://play.google.com/store/apps/details?id=com.jwork.spycamera">Google Play</a><br />
Source code: <a href="https://bitbucket.org/jimmod/spycamera">https://bitbucket.org/jimmod/spycamera</a></p>
<p>Features (version 0.1.0):<br />
- Small size application<br />
- Full/max camera resolution<br />
- Fast capture<br />
- Back/front camera<br />
- Auto shot with delay setting<br />
- Face detection auto shot<br />
- Black screen (touch to capture)<br />
- Pinch to zoom<br />
- Hide/show folder on Gallery<br />
- Vibration<br />
- Video Recording (New &amp; Experimental)<br />
- Save to internal/external storage</p>


<p>Related posts:<ol><li><a href='http://jimmod.com/blog/2012/07/jimmys-blog-adding-admobs-ads-to-android-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Adding AdMob&#8217;s ads to Android Application'>Jimmy&#8217;s Blog &#8211; Adding AdMob&#8217;s ads to Android Application</a></li><li><a href='http://jimmod.com/blog/2011/10/android-market-error-on-downloading-error-downloading-there-is-insufficient-space-on-the-device/' rel='bookmark' title='Permanent Link: Android Market error on downloading (Error Downloading. There is insufficient space on the device.)'>Android Market error on downloading (Error Downloading. There is insufficient space on the device.)</a></li><li><a href='http://jimmod.com/blog/2012/07/jimmys-blog-ab-slide-puzzle-for-android/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; AB Slide Puzzle for Android'>Jimmy&#8217;s Blog &#8211; AB Slide Puzzle for Android</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://jimmod.com/blog/2013/01/android-application-spy-camera-os-open-source/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Jimmy&#8217;s Blog &#8211; AB Slide Puzzle for Android</title>
		<link>http://jimmod.com/blog/2012/07/jimmys-blog-ab-slide-puzzle-for-android/</link>
		<comments>http://jimmod.com/blog/2012/07/jimmys-blog-ab-slide-puzzle-for-android/#comments</comments>
		<pubDate>Sun, 08 Jul 2012 17:07:16 +0000</pubDate>
		<dc:creator>jimmy</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[My Life]]></category>
		<category><![CDATA[ab]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[puzzle]]></category>
		<category><![CDATA[slide]]></category>
		<category><![CDATA[slide puzzle]]></category>
		<category><![CDATA[sliding]]></category>

		<guid isPermaLink="false">http://jimmod.com/blog/?p=285</guid>
		<description><![CDATA[AB Slide Puzzle is a new slide puzzle game for Android, you can find it here:
https://play.google.com/store/apps/details?id=com.jwork.slide
Addictive classic slide puzzle game, with rich features.
Sizes available from 3×3 for beginners until 10×10 for hardcore players.
Decide your puzzle image or random it either from your whole sdcard or from a specific folder.
No more boring time, with smooth sliding [...]


Related posts:<ol><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-slide-number-puzzle-game-with-echo2-framework/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Slide Number Puzzle Game with Echo2 Framework'>Jimmy&#8217;s Blog &#8211; Slide Number Puzzle Game with Echo2 Framework</a></li><li><a href='http://jimmod.com/blog/2011/10/android-market-error-on-downloading-error-downloading-there-is-insufficient-space-on-the-device/' rel='bookmark' title='Permanent Link: Android Market error on downloading (Error Downloading. There is insufficient space on the device.)'>Android Market error on downloading (Error Downloading. There is insufficient space on the device.)</a></li><li><a href='http://jimmod.com/blog/2008/09/displaying-row-number-rownum-in-mysql/' rel='bookmark' title='Permanent Link: Displaying row number (rownum) in MySQL'>Displaying row number (rownum) in MySQL</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>AB Slide Puzzle is a new slide puzzle game for Android, you can find it here:</p>
<p><a href="https://play.google.com/store/apps/details?id=com.jwork.slide">https://play.google.com/store/apps/details?id=com.jwork.slide</a></p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">Addictive classic slide puzzle game, with rich features.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">Sizes available from 3×3 for beginners until 10×10 for hardcore players.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">Decide your puzzle image or random it either from your whole sdcard or from a specific folder.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">No more boring time, with smooth sliding touch. Try to get the highest score.</div>
<p><span id="more-285"></span></p>
<p><a href="http://jimmod.com/blog/wp-content/uploads/2012/07/blog.jpg"><img class="aligncenter size-medium wp-image-283" title="blog" src="http://jimmod.com/blog/wp-content/uploads/2012/07/blog-300x166.jpg" alt="blog" width="300" height="166" /></a></p>
<p>Addictive classic slide puzzle game, with rich features.<br />
Sizes available from 3×3 for beginners until 10×10 for hardcore players.<br />
Decide your puzzle image or random it either from your whole sdcard or from a specific folder.<br />
No more boring time, with smooth sliding touch. Try to get the highest score.</p>


<p>Related posts:<ol><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-slide-number-puzzle-game-with-echo2-framework/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Slide Number Puzzle Game with Echo2 Framework'>Jimmy&#8217;s Blog &#8211; Slide Number Puzzle Game with Echo2 Framework</a></li><li><a href='http://jimmod.com/blog/2011/10/android-market-error-on-downloading-error-downloading-there-is-insufficient-space-on-the-device/' rel='bookmark' title='Permanent Link: Android Market error on downloading (Error Downloading. There is insufficient space on the device.)'>Android Market error on downloading (Error Downloading. There is insufficient space on the device.)</a></li><li><a href='http://jimmod.com/blog/2008/09/displaying-row-number-rownum-in-mysql/' rel='bookmark' title='Permanent Link: Displaying row number (rownum) in MySQL'>Displaying row number (rownum) in MySQL</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://jimmod.com/blog/2012/07/jimmys-blog-ab-slide-puzzle-for-android/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Jimmy&#8217;s Blog &#8211; Adding AdMob&#8217;s ads to Android Application</title>
		<link>http://jimmod.com/blog/2012/07/jimmys-blog-adding-admobs-ads-to-android-application/</link>
		<comments>http://jimmod.com/blog/2012/07/jimmys-blog-adding-admobs-ads-to-android-application/#comments</comments>
		<pubDate>Wed, 04 Jul 2012 11:20:08 +0000</pubDate>
		<dc:creator>jimmy</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[admob]]></category>
		<category><![CDATA[ads]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[iklan]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://jimmod.com/blog/?p=267</guid>
		<description><![CDATA[Finally I got some spare time to make new article on my blog  
One of the easy way to monetize our Android application is by adding ads.
This tutorial will give basic explanation  about how to add AdMob ads to Android Application.
Prerequisite:

AdMob SDK (https://developers.google.com/mobile-ads-sdk/download)
Your favorites IDE (I use Eclipse for this tutorial) for IDE


Create Android [...]


Related posts:<ol><li><a href='http://jimmod.com/blog/2013/01/android-application-spy-camera-os-open-source/' rel='bookmark' title='Permanent Link: Android Application &#8211; Spy Camera OS (Open Source)'>Android Application &#8211; Spy Camera OS (Open Source)</a></li><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-send-receiving-on-specific-port-with-j2me-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application'>Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application</a></li><li><a href='http://jimmod.com/blog/2010/04/basic-lwuit-tutorial-with-eclipse-pulsar/' rel='bookmark' title='Permanent Link: Basic LWUIT tutorial/sample with Eclipse Pulsar'>Basic LWUIT tutorial/sample with Eclipse Pulsar</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Finally I got some spare time to make new article on my blog <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>One of the easy way to monetize our Android application is by adding ads.<br />
This tutorial will give basic explanation  about how to add AdMob ads to Android Application.</p>
<p>Prerequisite:</p>
<ul>
<li>AdMob SDK (<a href="https://developers.google.com/mobile-ads-sdk/download">https://developers.google.com/mobile-ads-sdk/download</a>)</li>
<li>Your favorites IDE (I use Eclipse for this tutorial) for IDE</li>
</ul>
<p><span id="more-267"></span><br />
<strong>Create Android Project</strong></p>
<p>I create a simple android project with 1 activity and 1 layout.</p>
<p><strong>AdMob library</strong></p>
<p>Copy AdMob lib file (GoogleAdMobAdsSdk-6.0.1.jar) to your lib folder, so Eclipse will automatically include it to your build.<br />
And also add the library to project&#8217;s build path.</p>
<p><a href="http://jimmod.com/blog/wp-content/uploads/2012/07/package_explorer.png"><img class="aligncenter size-medium wp-image-268" title="Package Explorer" src="http://jimmod.com/blog/wp-content/uploads/2012/07/package_explorer-201x300.png" alt="Package Explorer" width="201" height="300" /></a></p>
<p><strong>Permissions and AdMob Activity</strong></p>
<p>There&#8217;s 2 things that we need to add to &#8216;AndroidManifest.xml&#8217;</p>
<ul>
<li> Permissions for &#8216;android.permission.INTERNET&#8217; and &#8216;android.permission.ACCESS_NETWORK_STATE&#8217;</li>
<li>AdMob &#8216;com.google.ads.AdActivity&#8217; Activity for handling configuration changes.</li>
</ul>
<p>AndroidManifest.xml</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;manifest</span> <span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">package</span>=<span style="color: #ff0000;">&quot;gnu.jimmod.android&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">android:versionCode</span>=<span style="color: #ff0000;">&quot;1&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">android:versionName</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;uses-sdk</span></span>
<span style="color: #009900;">        <span style="color: #000066;">android:minSdkVersion</span>=<span style="color: #ff0000;">&quot;8&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">android:targetSdkVersion</span>=<span style="color: #ff0000;">&quot;15&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;uses-permission</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.permission.INTERNET&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;uses-permission</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.permission.ACCESS_NETWORK_STATE&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;application</span></span>
<span style="color: #009900;">        <span style="color: #000066;">android:icon</span>=<span style="color: #ff0000;">&quot;@drawable/ic_launcher&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">android:label</span>=<span style="color: #ff0000;">&quot;@string/app_name&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">android:theme</span>=<span style="color: #ff0000;">&quot;@style/AppTheme&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;activity</span></span>
<span style="color: #009900;">            <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;.AdMobActivity&quot;</span></span>
<span style="color: #009900;">            <span style="color: #000066;">android:label</span>=<span style="color: #ff0000;">&quot;@string/title_activity_ad_mob&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intent-filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.intent.action.MAIN&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.intent.category.LAUNCHER&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/intent-filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/activity<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;activity</span></span>
<span style="color: #009900;">            <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;com.google.ads.AdActivity&quot;</span></span>
<span style="color: #009900;">            <span style="color: #000066;">android:configChanges</span>=<span style="color: #ff0000;">&quot;keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/manifest<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><strong>Adding Ads to Layout XML</strong></p>
<p>First way to add AdMob ad is by adding AdView to your XML layout.<br />
Parameter that need to be specified:</p>
<ul>
<li> ads:adUnitId : your AdMob app publisher ID</li>
<li>ads:adSize : ads size</li>
<li>ads:testDevices : list of testing devices (so only displaying dummy ads) &#8211; below there will be explanation how to know your device ID.</li>
<li>ads:loadAdOnCreate : boolean &#8211; ads will be automatically requested on layout displayed</li>
</ul>
<p>activity_admob.xml</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;LinearLayout</span> <span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span></span>
<span style="color: #009900;">                  <span style="color: #000066;">xmlns:ads</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/lib/com.google.ads&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">xmlns:tools</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/tools&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;match_parent&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;match_parent&quot;</span> </span>
<span style="color: #009900;">    <span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/layout&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">android:orientation</span>=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextView</span></span>
<span style="color: #009900;">        <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">android:padding</span>=<span style="color: #ff0000;">&quot;@dimen/padding_medium&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;@string/hello_world&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">tools:context</span>=<span style="color: #ff0000;">&quot;.AdMobActivity&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;com.google.ads.AdView</span> <span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/adView&quot;</span></span>
<span style="color: #009900;">                         <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span>
<span style="color: #009900;">                         <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span>
<span style="color: #009900;">                         <span style="color: #000066;">android:layout_gravity</span>=<span style="color: #ff0000;">&quot;center&quot;</span></span>
<span style="color: #009900;">                         <span style="color: #000066;">ads:adUnitId</span>=<span style="color: #ff0000;">&quot;a14ff402be4457c&quot;</span></span>
<span style="color: #009900;">                         <span style="color: #000066;">ads:adSize</span>=<span style="color: #ff0000;">&quot;BANNER&quot;</span></span>
<span style="color: #009900;">                         <span style="color: #000066;">ads:testDevices</span>=<span style="color: #ff0000;">&quot;TEST_EMULATOR&quot;</span></span>
<span style="color: #009900;">                         <span style="color: #000066;">ads:loadAdOnCreate</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/LinearLayout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><a href="http://jimmod.com/blog/wp-content/uploads/2012/07/admob_publisher_id.png"><img class="aligncenter size-medium wp-image-270" title="Admob Publisher ID" src="http://jimmod.com/blog/wp-content/uploads/2012/07/admob_publisher_id-300x153.png" alt="Admob Publisher ID" width="300" height="153" /></a></p>
<p><strong>Adding Ads via code</strong></p>
<p><span style="font-weight: bold;">Adding AdView at runtime is as simple as adding other Views. Same like adding in XML you will need to specify the publisher-ID, ads size and test device list.</span></p>
<p><span style="font-weight: bold;">AdMobActivity.java</span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">gnu.jimmod.android</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.app.Activity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os.Bundle</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.Menu</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.LinearLayout</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.ads.AdRequest</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.ads.AdSize</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.ads.AdView</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> AdMobActivity <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#123;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        setContentView<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">activity_admob</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        LinearLayout layout <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>LinearLayout<span style="color: #009900;">&#41;</span> findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">layout</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    AdView adView <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AdView<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, AdSize.<span style="color: #006633;">BANNER</span>, <span style="color: #0000ff;">&quot;a14ff402be4457c&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    layout.<span style="color: #006633;">addView</span><span style="color: #009900;">&#40;</span>adView<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    AdRequest adRequest <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AdRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    adRequest.<span style="color: #006633;">addTestDevice</span><span style="color: #009900;">&#40;</span>AdRequest.<span style="color: #006633;">TEST_EMULATOR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		adView.<span style="color: #006633;">loadAd</span><span style="color: #009900;">&#40;</span>adRequest<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onCreateOptionsMenu<span style="color: #009900;">&#40;</span><span style="color: #003399;">Menu</span> menu<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        getMenuInflater<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">inflate</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">menu</span>.<span style="color: #006633;">activity_admob</span>, menu<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><span style="font-weight: bold;">How to get my phone device-ID</span></p>
<p><span style="font-weight: ;">If you want to add your phone as test device, you will need to run your project with your phone via USB.<br />
Once you run it on your phone, there will be log in Eclipse LogCat window about your device-ID</span></p>
<p><span style="font-weight: ;"><a href="http://jimmod.com/blog/wp-content/uploads/2012/07/device_id1.png"><img class="aligncenter size-medium wp-image-273" title="device_id" src="http://jimmod.com/blog/wp-content/uploads/2012/07/device_id1-300x112.png" alt="device_id" width="300" height="112" /></a>Then you can copy and paste it to your code.</span></p>
<p><span style="font-weight: bold;"><strong>Screenshot</strong></span></p>
<p><span style="font-weight: ;"><a href="http://jimmod.com/blog/wp-content/uploads/2012/07/Screenshot.png"><img class="aligncenter size-medium wp-image-274" title="Screenshot" src="http://jimmod.com/blog/wp-content/uploads/2012/07/Screenshot-187x300.png" alt="Screenshot" width="187" height="300" /></a></span></p>
<p><span style="font-weight: bold;"><strong>Summary</strong></span></p>
<p><span style="font-weight: ;">Basically adding ads to your application is simple. We just need to be creative on how and when displaying the ads.<br />
I&#8217;m sure I will write more about ads on android, especially on ways to display ads on our apps.</span></p>
<p><span style="font-weight: ;">Until then..<br />
</span>Thank you for reading, hope this article able to help you.</p>
<p><span style="font-weight: bold;"><strong>Source Code</strong></span><br />
<span><br />
Download the tutorial source code here:<br />
<a href="https://bitbucket.org/jimmod/blog_android_admob/changeset/53f720effced">https://bitbucket.org/jimmod/blog_android_admob/changeset/53f720effced</a><br />
</span></p>


<p>Related posts:<ol><li><a href='http://jimmod.com/blog/2013/01/android-application-spy-camera-os-open-source/' rel='bookmark' title='Permanent Link: Android Application &#8211; Spy Camera OS (Open Source)'>Android Application &#8211; Spy Camera OS (Open Source)</a></li><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-send-receiving-on-specific-port-with-j2me-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application'>Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application</a></li><li><a href='http://jimmod.com/blog/2010/04/basic-lwuit-tutorial-with-eclipse-pulsar/' rel='bookmark' title='Permanent Link: Basic LWUIT tutorial/sample with Eclipse Pulsar'>Basic LWUIT tutorial/sample with Eclipse Pulsar</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://jimmod.com/blog/2012/07/jimmys-blog-adding-admobs-ads-to-android-application/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Got Android [Gingerbread] and want to run J2ME JAD/JAR (emulate J2ME app)?</title>
		<link>http://jimmod.com/blog/2012/03/got-android-gingerbread-and-want-to-run-j2me-jadjar-emulate-j2me-app/</link>
		<comments>http://jimmod.com/blog/2012/03/got-android-gingerbread-and-want-to-run-j2me-jadjar-emulate-j2me-app/#comments</comments>
		<pubDate>Wed, 14 Mar 2012 03:16:28 +0000</pubDate>
		<dc:creator>jimmy</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[cwm]]></category>
		<category><![CDATA[emulator]]></category>
		<category><![CDATA[j2me]]></category>
		<category><![CDATA[jad]]></category>
		<category><![CDATA[jar]]></category>
		<category><![CDATA[jbed]]></category>
		<category><![CDATA[root]]></category>

		<guid isPermaLink="false">http://jimmod.com/blog/?p=259</guid>
		<description><![CDATA[*Root-ed Android is required
This guide will help you to install J2ME emulator on your Android (mine is Gingerbread).
Case 1 : You have CMW (ClockWorldMod) installed.

 Copy Jbed_cmw.zip to your phone (http://dl.dropbox.com/u/45924042/jbed/Jbed_cmw.zip)
 Go to CMW recovery mode
 Flash the zip

Case 2 : Manual (I haven&#8217;t tested it – Do it with your own risk :p )

 [...]


Related posts:<ol><li><a href='http://jimmod.com/blog/2012/07/jimmys-blog-adding-admobs-ads-to-android-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Adding AdMob&#8217;s ads to Android Application'>Jimmy&#8217;s Blog &#8211; Adding AdMob&#8217;s ads to Android Application</a></li><li><a href='http://jimmod.com/blog/2011/10/android-market-error-on-downloading-error-downloading-there-is-insufficient-space-on-the-device/' rel='bookmark' title='Permanent Link: Android Market error on downloading (Error Downloading. There is insufficient space on the device.)'>Android Market error on downloading (Error Downloading. There is insufficient space on the device.)</a></li><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-send-receiving-on-specific-port-with-j2me-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application'>Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p><em><strong>*Root-ed Android is required</strong></em></p>
<p>This guide will help you to install J2ME emulator on your Android (mine is Gingerbread).</p>
<p><strong>Case 1 : You have CMW (ClockWorldMod) installed.</strong></p>
<ul>
<li> Copy Jbed_cmw.zip to your phone (http://dl.dropbox.com/u/45924042/jbed/Jbed_cmw.zip)</li>
<li> Go to CMW recovery mode</li>
<li> Flash the zip</li>
</ul>
<p><strong>Case 2 : Manual (I haven&#8217;t tested it – Do it with your own risk :p )</strong></p>
<ul>
<li> Copy Jbed.apk (http://dl.dropbox.com/u/45924042/jbed/Jbed.apk) to /system/app</li>
<li> Copy libjbedvm.so (http://dl.dropbox.com/u/45924042/jbed/libjbedvm.so) to /system/lib</li>
<li> Reboot your android</li>
</ul>
<p>After success installation you will see application &#8220;java&#8221; it can scan your sdcard for JAD &amp; JAR file.</p>
<p>Hurray&#8230;</p>


<p>Related posts:<ol><li><a href='http://jimmod.com/blog/2012/07/jimmys-blog-adding-admobs-ads-to-android-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Adding AdMob&#8217;s ads to Android Application'>Jimmy&#8217;s Blog &#8211; Adding AdMob&#8217;s ads to Android Application</a></li><li><a href='http://jimmod.com/blog/2011/10/android-market-error-on-downloading-error-downloading-there-is-insufficient-space-on-the-device/' rel='bookmark' title='Permanent Link: Android Market error on downloading (Error Downloading. There is insufficient space on the device.)'>Android Market error on downloading (Error Downloading. There is insufficient space on the device.)</a></li><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-send-receiving-on-specific-port-with-j2me-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application'>Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://jimmod.com/blog/2012/03/got-android-gingerbread-and-want-to-run-j2me-jadjar-emulate-j2me-app/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Android Market error on downloading (Error Downloading. There is insufficient space on the device.)</title>
		<link>http://jimmod.com/blog/2011/10/android-market-error-on-downloading-error-downloading-there-is-insufficient-space-on-the-device/</link>
		<comments>http://jimmod.com/blog/2011/10/android-market-error-on-downloading-error-downloading-there-is-insufficient-space-on-the-device/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 17:26:09 +0000</pubDate>
		<dc:creator>jimmy</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[My Life]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[device]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[insufficient]]></category>
		<category><![CDATA[market]]></category>
		<category><![CDATA[on]]></category>
		<category><![CDATA[size]]></category>
		<category><![CDATA[space]]></category>
		<category><![CDATA[the]]></category>

		<guid isPermaLink="false">http://jimmod.com/blog/?p=255</guid>
		<description><![CDATA[Today suddenly when I want to download an application from my Android tablet, I receiving this error : &#8220;Error Downloading xyzxyz. There is insufficient space on the device.&#8221;
It&#8217;s only displaying the error on downloading application with big size.
After browsing around, I found out that the cache folder (that I assume used by the market) is [...]


Related posts:<ol><li><a href='http://jimmod.com/blog/2012/03/got-android-gingerbread-and-want-to-run-j2me-jadjar-emulate-j2me-app/' rel='bookmark' title='Permanent Link: Got Android [Gingerbread] and want to run J2ME JAD/JAR (emulate J2ME app)?'>Got Android [Gingerbread] and want to run J2ME JAD/JAR (emulate J2ME app)?</a></li><li><a href='http://jimmod.com/blog/2012/07/jimmys-blog-ab-slide-puzzle-for-android/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; AB Slide Puzzle for Android'>Jimmy&#8217;s Blog &#8211; AB Slide Puzzle for Android</a></li><li><a href='http://jimmod.com/blog/2012/07/jimmys-blog-adding-admobs-ads-to-android-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Adding AdMob&#8217;s ads to Android Application'>Jimmy&#8217;s Blog &#8211; Adding AdMob&#8217;s ads to Android Application</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Today suddenly when I want to download an application from my Android tablet, I receiving this error : &#8220;Error Downloading xyzxyz. There is insufficient space on the device.&#8221;<br />
It&#8217;s only displaying the error on downloading application with big size.</p>
<p>After browsing around, I found out that the cache folder (that I assume used by the market) is using small partition (around 20mb in my case).<br />
<span id="more-255"></span><br />
So to solve this we need to change it to bigger partition.</p>
<ol>
<li>You gonna need Android Terminal Simulator or equivalent terminal app. This will also require your Android rooted.</li>
<li> Type &#8217;su&#8217; (root permission request will be showned, you need to approve it).</li>
<li>Type &#8216;cd /&#8217;</li>
<li>Type &#8216;umount /cache&#8217;</li>
<li>Type &#8216;mount -o rw,remount -t rootfs rootfs /&#8217; (to set the folder access to rw &#8211; read write)</li>
<li>Type &#8216;rmdir /cache&#8217; (delete cache folder)</li>
<li>I personally using root explorer to do point 5-6</li>
<li>Type &#8216;mkdir /sdcard/cache&#8217;</li>
<li>Type &#8216;ln -s /sdcard/cache /cache&#8217; (to link cache folder to /sdcard/cache &#8211; which shoud have bigger partition size)</li>
</ol>
<p>Done.<br />
Try to rerun your Android Market and download big applications</p>


<p>Related posts:<ol><li><a href='http://jimmod.com/blog/2012/03/got-android-gingerbread-and-want-to-run-j2me-jadjar-emulate-j2me-app/' rel='bookmark' title='Permanent Link: Got Android [Gingerbread] and want to run J2ME JAD/JAR (emulate J2ME app)?'>Got Android [Gingerbread] and want to run J2ME JAD/JAR (emulate J2ME app)?</a></li><li><a href='http://jimmod.com/blog/2012/07/jimmys-blog-ab-slide-puzzle-for-android/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; AB Slide Puzzle for Android'>Jimmy&#8217;s Blog &#8211; AB Slide Puzzle for Android</a></li><li><a href='http://jimmod.com/blog/2012/07/jimmys-blog-adding-admobs-ads-to-android-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Adding AdMob&#8217;s ads to Android Application'>Jimmy&#8217;s Blog &#8211; Adding AdMob&#8217;s ads to Android Application</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://jimmod.com/blog/2011/10/android-market-error-on-downloading-error-downloading-there-is-insufficient-space-on-the-device/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>Java ME (J2ME) JSON Implementation For Array Object</title>
		<link>http://jimmod.com/blog/2011/09/java-me-j2me-json-implementation-for-array-object/</link>
		<comments>http://jimmod.com/blog/2011/09/java-me-j2me-json-implementation-for-array-object/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 16:47:04 +0000</pubDate>
		<dc:creator>jimmy</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[j2me]]></category>
		<category><![CDATA[javame]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://jimmod.com/blog/?p=246</guid>
		<description><![CDATA[One of the comment in JSON ME tutorial (http://jimmod.com/blog/2010/03/java-me-j2me-json-implementation-tutorialsample/) asking about how to parse this kind of JSON :

&#123;\”api_status\”: \”OK\”,\”threads\”: &#91;&#123;\&#34;tid\&#34;: \&#34;2\&#34;,\&#34;title\&#34;: \&#34;First Title\&#34; }, { \&#34;tid\&#34;: \&#34;4\&#34;, \&#34;title\&#34;: \&#34;this is 2nd Title\&#34;}]}
&#60;span id=&#34;more-246&#34;&#62;&#60;/span&#62;

Latest JSON ME library : https://github.com/upictec/org.json.me/
From the JSON format we can easily see that the object have 2 property:

api_status : String
threads : [...]


Related posts:<ol><li><a href='http://jimmod.com/blog/2010/03/java-me-j2me-json-implementation-tutorialsample/' rel='bookmark' title='Permanent Link: Java ME (J2ME) JSON Implementation Tutorial/Sample'>Java ME (J2ME) JSON Implementation Tutorial/Sample</a></li><li><a href='http://jimmod.com/blog/2007/12/using-mock-object-with-jmock-2/' rel='bookmark' title='Permanent Link: Using mock object with jmock 2'>Using mock object with jmock 2</a></li><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-send-receiving-on-specific-port-with-j2me-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application'>Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>One of the comment in JSON ME tutorial (<a href="../2010/03/java-me-j2me-json-implementation-tutorialsample/">http://jimmod.com/blog/2010/03/java-me-j2me-json-implementation-tutorialsample/</a>) asking about how to parse this kind of JSON :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>\”api_status\”<span style="color: #339933;">:</span> \”OK\”,\”threads\”<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>\<span style="color: #0000ff;">&quot;tid<span style="color: #000099; font-weight: bold;">\&quot;</span>: <span style="color: #000099; font-weight: bold;">\&quot;</span>2<span style="color: #000099; font-weight: bold;">\&quot;</span>,<span style="color: #000099; font-weight: bold;">\&quot;</span>title<span style="color: #000099; font-weight: bold;">\&quot;</span>: <span style="color: #000099; font-weight: bold;">\&quot;</span>First Title<span style="color: #000099; font-weight: bold;">\&quot;</span> }, { <span style="color: #000099; font-weight: bold;">\&quot;</span>tid<span style="color: #000099; font-weight: bold;">\&quot;</span>: <span style="color: #000099; font-weight: bold;">\&quot;</span>4<span style="color: #000099; font-weight: bold;">\&quot;</span>, <span style="color: #000099; font-weight: bold;">\&quot;</span>title<span style="color: #000099; font-weight: bold;">\&quot;</span>: <span style="color: #000099; font-weight: bold;">\&quot;</span>this is 2nd Title<span style="color: #000099; font-weight: bold;">\&quot;</span>}]}
&lt;span id=&quot;</span>more<span style="color: #339933;">-</span><span style="color: #cc66cc;">246</span><span style="color: #0000ff;">&quot;&gt;&lt;/span&gt;</span></pre></div></div>

<p>Latest JSON ME library : <a href="https://github.com/upictec/org.json.me/">https://github.com/upictec/org.json.me/</a></p>
<p>From the JSON format we can easily see that the object have 2 property:</p>
<ul>
<li>api_status : String</li>
<li>threads : Array of object</li>
</ul>
<p>The Threads Object:</p>
<ul>
<li>tid : Integer</li>
<li>title : String</li>
</ul>
<p>My solution is not exactly the same because I have different approach on handling the arrays.</p>
<p>First I will make the threads class, I name it ThreadData. It should also implement the JSONable interface (<a href="http://jimmod.com/blog/2010/03/java-me-j2me-json-implementation-tutorialsample/" target="_blank">see the 1st tutorial for the code</a>).</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> ThreadData <span style="color: #000000; font-weight: bold;">implements</span> JSONAble <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> tid<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> title<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> getTid<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> tid<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setTid<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> tid<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">tid</span> <span style="color: #339933;">=</span> tid<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getTitle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> title<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setTitle<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> title<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">title</span> <span style="color: #339933;">=</span> title<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> fromJSON<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> jsonString<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			JSONObject json <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span>jsonString<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			setTid<span style="color: #009900;">&#40;</span>json.<span style="color: #006633;">getInt</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;tid&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			setTitle<span style="color: #009900;">&#40;</span>json.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;title&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>JSONException ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			ex.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> toJSON<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		JSONObject inner <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			inner.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;tid&quot;</span>, getTid<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			inner.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;title&quot;</span>, getTitle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>JSONException ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			ex.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> inner.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> toString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> getTid<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;-&quot;</span> <span style="color: #339933;">+</span> getTitle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Above implementation is just like the <a href="http://jimmod.com/blog/2010/03/java-me-j2me-json-implementation-tutorialsample/" target="_blank">1st tutorial</a>, the main class JSONable implementation is different. Please focus on the JSONArray usage.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Response <span style="color: #000000; font-weight: bold;">implements</span> JSONAble <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> api_status<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> ThreadData<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> threads<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getApi_status<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> api_status<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setApi_status<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> apiStatus<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		api_status <span style="color: #339933;">=</span> apiStatus<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> ThreadData<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> getThreads<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> threads<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setThreads<span style="color: #009900;">&#40;</span>ThreadData<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> threads<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">threads</span> <span style="color: #339933;">=</span> threads<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> 
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> fromJSON<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> jsonString<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			JSONObject json <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span>jsonString<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			setApi_status<span style="color: #009900;">&#40;</span>json.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;api_status&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			JSONArray jsonArray <span style="color: #339933;">=</span> json.<span style="color: #006633;">getJSONArray</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;threads&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">int</span> total <span style="color: #339933;">=</span> jsonArray.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			ThreadData<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> threads <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ThreadData<span style="color: #009900;">&#91;</span>total<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>total<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003399;">String</span> threadsJSON <span style="color: #339933;">=</span> jsonArray.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				threads<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ThreadData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				threads<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">fromJSON</span><span style="color: #009900;">&#40;</span>threadsJSON<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			setThreads<span style="color: #009900;">&#40;</span>threads<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>JSONException ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			ex.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> toJSON<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		JSONObject inner <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			inner.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;api_status&quot;</span>, getApi_status<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			JSONArray jsonArray <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONArray<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			ThreadData<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> threads <span style="color: #339933;">=</span> getThreads<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>threads.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				jsonArray.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>threads<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">toJSON</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			inner.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;threads&quot;</span>, jsonArray<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>JSONException ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			ex.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> inner.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> toString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">String</span> response <span style="color: #339933;">=</span> getApi_status<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">;</span>
		ThreadData<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> threads <span style="color: #339933;">=</span> getThreads<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>threads.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			response <span style="color: #339933;">+=</span> <span style="color: #0000ff;">&quot;[&quot;</span> <span style="color: #339933;">+</span> threads<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;]&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> response<span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>So when you setup the startapp function:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> startApp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> MIDletStateChangeException <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//Converting Object to JSON</span>
		Response response <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Response<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		ThreadData<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> threads <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ThreadData<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		threads<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ThreadData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		threads<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">setTid</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		threads<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">setTitle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;First Title&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		threads<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ThreadData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		threads<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">setTid</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		threads<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">setTitle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;this is 2nd Title&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		response.<span style="color: #006633;">setApi_status</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;OK&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		response.<span style="color: #006633;">setThreads</span><span style="color: #009900;">&#40;</span>threads<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Convert to JSON : &quot;</span><span style="color: #339933;">+</span>response.<span style="color: #006633;">toJSON</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		<span style="color: #666666; font-style: italic;">//Converting JSON to Object</span>
		<span style="color: #003399;">String</span> sample <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;{<span style="color: #000099; font-weight: bold;">\&quot;</span>api_status<span style="color: #000099; font-weight: bold;">\&quot;</span>:<span style="color: #000099; font-weight: bold;">\&quot;</span>SAMPLE<span style="color: #000099; font-weight: bold;">\&quot;</span>,<span style="color: #000099; font-weight: bold;">\&quot;</span>threads<span style="color: #000099; font-weight: bold;">\&quot;</span>:[<span style="color: #000099; font-weight: bold;">\&quot;</span>{<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\&quot;</span>tid<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\&quot;</span>:10,<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\&quot;</span>title<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\&quot;</span>:<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\&quot;</span>3rdTitle<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\&quot;</span>}<span style="color: #000099; font-weight: bold;">\&quot;</span>,<span style="color: #000099; font-weight: bold;">\&quot;</span>{<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\&quot;</span>tid<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\&quot;</span>:15,<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\&quot;</span>title<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\&quot;</span>:<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\&quot;</span>this is 4th Title<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\&quot;</span>}<span style="color: #000099; font-weight: bold;">\&quot;</span>]}&quot;</span><span style="color: #339933;">;</span>
		Response reponse <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Response<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		response.<span style="color: #006633;">fromJSON</span><span style="color: #009900;">&#40;</span>sample<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Convert from JSON : &quot;</span><span style="color: #339933;">+</span> response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>It will have output:</p>

<div class="wp_syntax"><div class="code"><pre class="json" style="font-family:monospace;">Convert to JSON : {&quot;api_status&quot;:&quot;OK&quot;,&quot;threads&quot;:[&quot;{\&quot;tid\&quot;:2,\&quot;title\&quot;:\&quot;First Title\&quot;}&quot;,&quot;{\&quot;tid\&quot;:4,\&quot;title\&quot;:\&quot;this is 2nd Title\&quot;}&quot;]}
Convert from JSON : SAMPLE-[10-3rdTitle][15-this is 4th Title]</pre></div></div>

<p>It demonstrate the sample for creating JSON string and parsing JSON string which have array/object inside the JSON.</p>
<p></code></p>


<p>Related posts:<ol><li><a href='http://jimmod.com/blog/2010/03/java-me-j2me-json-implementation-tutorialsample/' rel='bookmark' title='Permanent Link: Java ME (J2ME) JSON Implementation Tutorial/Sample'>Java ME (J2ME) JSON Implementation Tutorial/Sample</a></li><li><a href='http://jimmod.com/blog/2007/12/using-mock-object-with-jmock-2/' rel='bookmark' title='Permanent Link: Using mock object with jmock 2'>Using mock object with jmock 2</a></li><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-send-receiving-on-specific-port-with-j2me-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application'>Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://jimmod.com/blog/2011/09/java-me-j2me-json-implementation-for-array-object/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Build and Parse ISO Message using JPOS library</title>
		<link>http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/</link>
		<comments>http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 12:42:27 +0000</pubDate>
		<dc:creator>jimmy</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[8583]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[iso]]></category>
		<category><![CDATA[iso 8583]]></category>
		<category><![CDATA[jimmy]]></category>
		<category><![CDATA[jpos]]></category>
		<category><![CDATA[pack]]></category>
		<category><![CDATA[packager]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[unpack]]></category>

		<guid isPermaLink="false">http://jimmod.com/blog/?p=225</guid>
		<description><![CDATA[ISO 8583 Tutorial article

Introduction for Beginners
Build and Parse ISO Message using JPOS library
????

In the beginning
OK after my article about ISO 8583 let&#8217;s go deeper into programming using Java + JPOS library.
Quote from JPOS website:
jPOS is a Java® platform-based, mission-critical, ISO-8583 based financial transaction library/framework that can be customized and extended in order to implement financial [...]


Related posts:<ol><li><a href='http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Introduction for Beginners'>Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Introduction for Beginners</a></li><li><a href='http://jimmod.com/blog/2010/03/java-me-j2me-json-implementation-tutorialsample/' rel='bookmark' title='Permanent Link: Java ME (J2ME) JSON Implementation Tutorial/Sample'>Java ME (J2ME) JSON Implementation Tutorial/Sample</a></li><li><a href='http://jimmod.com/blog/2007/11/simple-log4j-implementation/' rel='bookmark' title='Permanent Link: Simple Log4J implementation'>Simple Log4J implementation</a></li></ol>]]></description>
			<content:encoded><![CDATA[<h2 style="font-size: 1.5em;"><strong>ISO 8583 Tutorial article</strong></h2>
<ul>
<li><a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/">Introduction for Beginners</a></li>
<li><a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/">Build and Parse ISO Message using JPOS library</a></li>
<li>????</li>
</ul>
<h2><strong>In the beginning</strong></h2>
<p>OK after <a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/">my article about ISO 8583</a> let&#8217;s go deeper into programming using Java + JPOS library.</p>
<p>Quote from <a href="http://www.jpos.org/" target="_blank">JPOS website</a>:</p>
<blockquote><p>jPOS is a Java® platform-based, mission-critical, ISO-8583 based financial transaction library/framework that can be customized and extended in order to implement financial interchanges.</p></blockquote>
<p>So first thing to do is download JPOS from it website.</p>
<p>Then we setup our development environment by creating Java Project using your favorites IDE. Add to the project all jar in JPOS library.<br />
Here&#8217;s my Eclipse  package explorer looks like.<br />
<span id="more-225"></span></p>
<div id="attachment_226" class="wp-caption aligncenter" style="width: 306px"><a href="http://jimmod.com/blog/wp-content/uploads/2011/07/package-explorer.png"><img class="size-medium wp-image-226" title="package explorer" src="http://jimmod.com/blog/wp-content/uploads/2011/07/package-explorer-296x300.png" alt="package explorer" width="296" height="300" /></a><p class="wp-caption-text">package explorer</p></div>
<h2><strong>Create Data Elements (DE) types XML</strong></h2>
<p>Like I said that ISO 8583 is a &#8217;standard&#8217; which mean can be different between one implementation and another <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
To put it simple, although there&#8217;s a (some) standard for DE list sometime we need to change it.<br />
Either way, we need to tell JPOS how our DE will be formatted or packaged.</p>
<p>Since in the complete XML there&#8217;s 128 DE, I&#8217;ll quote only the DE # we used. Full xml can be <a href="http://jimmod.com/blog/wp-content/uploads/2011/07/basic.xml">downloaded here (basic.xml)</a></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span> <span style="color: #000066;">standalone</span>=<span style="color: #ff0000;">&quot;no&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE isopackager SYSTEM &quot;genericpackager.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isopackager<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;4&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;MESSAGE TYPE INDICATOR&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_NUMERIC&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;1&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;64&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;BIT MAP&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_BITMAP&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;3&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;6&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;PROCESSING CODE&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_NUMERIC&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;4&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;12&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;AMOUNT, TRANSACTION&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_NUMERIC&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;7&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;10&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;TRANSMISSION DATE AND TIME&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_NUMERIC&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;11&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;6&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SYSTEM TRACE AUDIT NUMBER&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_NUMERIC&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;44&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;25&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ADITIONAL RESPONSE DATA&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_LLCHAR&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;105&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;999&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;RESERVED ISO USE&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_LLLCHAR&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/isopackager<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The XML should easily understand in each isofield tag we define:</p>
<ul>
<li>id : the DE number</li>
<li>length : the max/fixed length of the DE</li>
<li>name : yes, it&#8217;s the name or description</li>
<li>class : this define the type of the DE, which in this case represent by the JPOS class. You can see the whole <a href="http://www.jpos.org/doc/javadoc/org/jpos/iso/package-summary.html" target="_blank">class list here</a>. I only list some of it.
<ul>
<li>IFA_NUMERIC : Numeric &#8211; Left padder with zeros.</li>
<li>IFA_BITMAP : For ISO Bitmap</li>
<li>IFA_LLCHAR : ASCII variable len CHAR &#8211; 2 digit length info</li>
<li>IFA_LLLCHAR : ASCII variable len CHAR &#8211; 3 digit length info</li>
</ul>
</li>
</ul>
<p>So this XML will be used for build (pack) ISO Message or parse (unpack) ISO Message.</p>
<p>You will need the <a href="http://jimmod.com/blog/wp-content/uploads/2011/07/genericpackager.dtd">XML data schema (genericpackager.dtd)</a> to be put on same directory with basic.xml</p>
<h2 style="font-size: 1.5em;">Build (pack) ISO Message</h2>
<p>Below is the code. The code is quite straight forward, review it first and I&#8217;ll discuss a bit afterward.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">gnu.jimmod.iso8583.utility</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.ISOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.ISOMsg</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.packager.GenericPackager</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BuildISOMessage <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span>, ISOException <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Create Packager based on XML that contain DE type</span>
		GenericPackager packager <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GenericPackager<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;basic.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Create ISO Message</span>
		ISOMsg isoMsg <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ISOMsg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">setPackager</span><span style="color: #009900;">&#40;</span>packager<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">setMTI</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;0200&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span>, <span style="color: #0000ff;">&quot;201234&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">4</span>, <span style="color: #0000ff;">&quot;10000&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">7</span>, <span style="color: #0000ff;">&quot;110722180&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">11</span>, <span style="color: #0000ff;">&quot;123456&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">44</span>, <span style="color: #0000ff;">&quot;A5DFGR&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">105</span>, <span style="color: #0000ff;">&quot;ABCDEFGHIJ 1234567890&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// print the DE list</span>
		logISOMsg<span style="color: #009900;">&#40;</span>isoMsg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Get and print the output result</span>
		<span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> data <span style="color: #339933;">=</span> isoMsg.<span style="color: #006633;">pack</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;RESULT : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> logISOMsg<span style="color: #009900;">&#40;</span>ISOMsg msg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;----ISO MESSAGE-----&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;  MTI : &quot;</span> <span style="color: #339933;">+</span> msg.<span style="color: #006633;">getMTI</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span>msg.<span style="color: #006633;">getMaxField</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>msg.<span style="color: #006633;">hasField</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;    Field-&quot;</span><span style="color: #339933;">+</span>i<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; : &quot;</span><span style="color: #339933;">+</span>msg.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>ISOException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;--------------------&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The output:</p>
<pre>----ISO MESSAGE-----
  MTI : 0200
    Field-3 : 201234
    Field-4 : 10000
    Field-7 : 110722180
    Field-11 : 123456
    Field-44 : A5DFGR
    Field-105 : ABCDEFGHIJ 1234567890
--------------------
RESULT : 0200B2200000001000000000000000800000201234000000010000011072218012345606A5DFGR021ABCDEFGHIJ 1234567890</pre>
<p>The program flow:</p>
<ol>
<li>Create ISO packager based on the xml file.</li>
<li>Set the DE values. I use <a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/" target="_blank">the previous article</a> examples.</li>
<li>Print the DE values set.</li>
<li>Pack the message.</li>
<li>Print the formatted ISO message. As you can see the result is the same with <a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/" target="_blank">the previous article</a> examples.</li>
</ol>
<h2 style="font-size: 1.5em;">Parse (unpack) ISO Message</h2>
<p>On this case it&#8217;s reversed. We have the ISO Message, and we need to see the DE values of it.<br />
Like the previous code this one also similar and should be easy to understand.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">gnu.jimmod.iso8583.utility</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.ISOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.ISOMsg</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.packager.GenericPackager</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ParseISOMessage <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span>, ISOException <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Create Packager based on XML that contain DE type</span>
		GenericPackager packager <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GenericPackager<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;basic.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Print Input Data</span>
		<span style="color: #003399;">String</span> data <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;0200B2200000001000000000000000800000201234000000010000011072218012345606A5DFGR021ABCDEFGHIJ 1234567890&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DATA : &quot;</span> <span style="color: #339933;">+</span> data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Create ISO Message</span>
		ISOMsg isoMsg <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ISOMsg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">setPackager</span><span style="color: #009900;">&#40;</span>packager<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">unpack</span><span style="color: #009900;">&#40;</span>data.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// print the DE list</span>
		logISOMsg<span style="color: #009900;">&#40;</span>isoMsg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> logISOMsg<span style="color: #009900;">&#40;</span>ISOMsg msg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;----ISO MESSAGE-----&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;  MTI : &quot;</span> <span style="color: #339933;">+</span> msg.<span style="color: #006633;">getMTI</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span>msg.<span style="color: #006633;">getMaxField</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>msg.<span style="color: #006633;">hasField</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;    Field-&quot;</span><span style="color: #339933;">+</span>i<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; : &quot;</span><span style="color: #339933;">+</span>msg.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>ISOException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;--------------------&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The output:</p>
<pre>DATA : 0200B2200000001000000000000000800000201234000000010000011072218012345606A5DFGR021ABCDEFGHIJ 1234567890
----ISO MESSAGE-----
  MTI : 0200
    Field-3 : 201234
    Field-4 : 000000010000
    Field-7 : 0110722180
    Field-11 : 123456
    Field-44 : A5DFGR
    Field-105 : ABCDEFGHIJ 1234567890
--------------------</pre>
<p>The program flow:</p>
<ol>
<li>Create ISO packager based on the xml file.</li>
<li>Set ISO Message.</li>
<li>Print the ISO Message.</li>
<li>Unpack the message.</li>
<li>Print the DE values. As you can see the result is correct, just like the DE set in first example.</li>
</ol>
<h2 style="font-size: 1.5em;"><strong>In the end</strong></h2>
<p>Ok, like always I hope I make it clear for you.<br />
This might not (yet) a tutorial to make you able the whole financial platform or a bank platform <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
But everyone need to start somewhere.</p>
<p>I see this code example as the implementation of <a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/">my previous article (ISO 8583 introduction)</a></p>
<p><a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/"></a>Just leave comment if you have questions.</p>


<p>Related posts:<ol><li><a href='http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Introduction for Beginners'>Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Introduction for Beginners</a></li><li><a href='http://jimmod.com/blog/2010/03/java-me-j2me-json-implementation-tutorialsample/' rel='bookmark' title='Permanent Link: Java ME (J2ME) JSON Implementation Tutorial/Sample'>Java ME (J2ME) JSON Implementation Tutorial/Sample</a></li><li><a href='http://jimmod.com/blog/2007/11/simple-log4j-implementation/' rel='bookmark' title='Permanent Link: Simple Log4J implementation'>Simple Log4J implementation</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/feed/</wfw:commentRss>
		<slash:comments>62</slash:comments>
		</item>
		<item>
		<title>Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Introduction for Beginners</title>
		<link>http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/</link>
		<comments>http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 09:46:23 +0000</pubDate>
		<dc:creator>jimmy</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[8583]]></category>
		<category><![CDATA[bank]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[financial]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[iso]]></category>
		<category><![CDATA[iso 8583]]></category>
		<category><![CDATA[jimmy]]></category>
		<category><![CDATA[message]]></category>
		<category><![CDATA[standard]]></category>
		<category><![CDATA[tcp]]></category>
		<category><![CDATA[transaction]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://jimmod.com/blog/?p=209</guid>
		<description><![CDATA[ISO 8583 Tutorial article

Introduction for Beginners
Build and Parse ISO Message using JPOS library
????


Introduction
Lately I&#8217;ve handle several financial project that allow me to understand bank and financial transaction better.
All (or most?) financial transaction is using ISO 8583 standard, which at first I thought is a complicated standard. But after learn and see how it implemented it&#8217;s [...]


Related posts:<ol><li><a href='http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Build and Parse ISO Message using JPOS library'>Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Build and Parse ISO Message using JPOS library</a></li><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-send-receiving-on-specific-port-with-j2me-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application'>Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application</a></li><li><a href='http://jimmod.com/blog/2010/04/basic-lwuit-tutorial-with-eclipse-pulsar/' rel='bookmark' title='Permanent Link: Basic LWUIT tutorial/sample with Eclipse Pulsar'>Basic LWUIT tutorial/sample with Eclipse Pulsar</a></li></ol>]]></description>
			<content:encoded><![CDATA[<h2 style="font-size: 1.5em;"><strong style="font-weight: bold;">ISO 8583 Tutorial article</strong></h2>
<ul>
<li><a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/">Introduction for Beginners</a></li>
<li><a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/">Build and Parse ISO Message using JPOS library</a></li>
<li>????</li>
</ul>
<ul></ul>
<h2><strong>Introduction</strong></h2>
<p>Lately I&#8217;ve handle several financial project that allow me to understand bank and financial transaction better.<br />
All (or most?) financial transaction is using ISO 8583 standard, which at first I thought is a complicated standard. But after learn and see how it implemented it&#8217;s not as complex as I thought.<br />
In this post I will try to explain (based on my experience <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  before I go deeper on the programming side.<br />
<span id="more-209"></span><br />
Although it&#8217;s a &#8217;standard&#8217; I see that&#8217;s many variant for the detail implementation of ISO 8583.</p>
<p>Financial transaction is communication between 2 system through socket connection.<br />
After connection established, each system can send message in ISO 8583 format which commonly will be request and the other system will response.<br />
From my experience the communication will be start with sign on and then the financial transactions.<br />
Periodically an echo message is send to make sure the other system is still alive.</p>
<p>If I break down the flow:</p>
<ol>
<li>System A open connection to System B (through specific IP and Port).</li>
<li>Connection established.</li>
<li>System A send Sign-On request message.</li>
<li>System B send Sign-on response message.</li>
<li>System A will start send Echo request message periodically (e.g every 1 minute).</li>
<li>System B will send Echo response message when receive Echo request message.</li>
<li>When financial transaction happen, System A will send Transaction request message.</li>
<li>Then System B will send Transaction response message.</li>
<li>If something wrong happen (usually timeout so System A didn&#8217;t get the response), System A will send Reversal request message to cancel the previous transaction.</li>
<li>System B will send Reversal response message.</li>
</ol>
<p>I hope my explaination give clear basic understanding about the flow.<br />
Next the question will be what&#8217;s this ISO 8583 message looks like.<br />
We can separate the message into 3 parts:</p>
<ul>
<li>Message Type Identifier</li>
<li>Bitmaps</li>
<li>Data Elements</li>
</ul>
<p style="text-align: center; "><strong> </strong></p>
<div id="attachment_216" class="wp-caption aligncenter" style="width: 310px"><a href="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-structure.png"><img class="size-medium wp-image-216" title="ISO8583 - structure" src="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-structure-300x28.png" alt="ISO8583 - structure" width="300" height="28" /></a><p class="wp-caption-text">ISO8583 - structure</p></div>
<h2><strong>Message Type Identifier</strong></h2>
<p>Message Type Identifier or MTI is 4 digits numeric that describe the message type. It will explain the message function.<br />
Commonly used:<br />
- 02xx : Financial Message (e.g 0200 for request, 0210 for response)<br />
- 04xx : Reversal Message (e.g 0400 for request, 0410 for response)<br />
- 08xx : Network Management Message (e.g 0800 for request, 0810 for response)<br />
* I found more detail &amp; complete list at <a title="wikipedia" href="http://en.wikipedia.org/wiki/ISO_8583" target="_blank">wikipedia</a></p>
<h2><strong>Bitmaps</strong></h2>
<p>Bitmaps is field that contain information about which data element is presence or absence. Based on the variant it could be 16 hexadecimal characters.<br />
An example will make it clear.</p>
<p>The bitmap is:</p>
<p style="text-align: center;">B220000000100000</p>
<p>If we break down to binary (I hope you understand how to convert hexadecimal to binary:) :</p>
<p style="text-align: center;">1011001000100000000000000000000000000000000100000000000000000000</p>
<p>Since I&#8217;m nice <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  I create graphical illustration.</p>
<div id="attachment_211" class="wp-caption aligncenter" style="width: 310px"><a href="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-bitmaps.png"><img class="size-medium wp-image-211" title="ISO8583 - bitmaps" src="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-bitmaps-300x8.png" alt="Bitmap sample" width="300" height="8" /></a><p class="wp-caption-text">Bitmap sample</p></div>
<p>You can see that in this bitmap it explain that data element in the message is 1, 3, 4, 7, 11.<br />
There&#8217;s special meaning of first bit of bitmap, if it has value of 1 that mean there&#8217;s secondary bitmap.<br />
And what the hell is this secondary bitmap?<br />
Since 16 hexadecimal characters will can only contain info of 64 data element, some transactions contain data element number 64 &#8211; 128. That mean the 16 hexadecimal characters is not sufficient.<br />
With set the first bit to &#8216;1&#8242; that will inform there&#8217;s additional bitmap, which is another 16 hexadecimal characters.<br />
So in this case the full bitmap example should be:<br />
B220000000100000<strong>0000000000800000</strong><br />
Convert to binary:<br />
1011001000100000000000000000000000000000000100000000000000000000<strong>0000000000000000000000000000000000000000100000000000000000000000</strong><br />
From the bitmap, data element presence in the message : 3, 4, 7, 11, 105.</p>
<div id="attachment_212" class="wp-caption aligncenter" style="width: 310px"><a href="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-bitmaps-2.png"><img class="size-medium wp-image-212" title="ISO8583 - bitmaps - 2" src="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-bitmaps-2-300x20.png" alt="Sample Bitmap complete" width="300" height="20" /></a><p class="wp-caption-text">Sample Bitmap complete</p></div>
<h2>Data Elements</h2>
<p>Data Elements is the essense of the whole ISO message, contain information about the transaction (transaction type, amount, customer id, etc).<br />
Each data element have their on format, attribute and length.<br />
Each data element number also have standard purpose, for example DE #4 is transaction amount.<br />
I will explain based on the example above, since this is only introduction I don&#8217;t want to confuse beginner reader. In <a href="http://en.wikipedia.org/wiki/ISO_8583#Data_elements" target="_blank">wikipedia </a> there&#8217;s full list.<br />
For our examples, the data element list:</p>
<ul>
<li>#3 &#8211; Processing code &#8211; n 6</li>
<li>#4 &#8211; Transaction amount &#8211; n 12</li>
<li>#7 &#8211; Transmission date &amp; time &#8211; n 10</li>
<li>#11 &#8211; Systems trace audit number &#8211; n 6</li>
<li>#44 &#8211; Additional response data &#8211; an ..25</li>
<li>#105 &#8211; Reserved for ISO use &#8211; ans &#8230;999</li>
</ul>
<p>To make it practical let&#8217;s just use example.<br />
We want to send :</p>
<ul>
<li>DE #3 : 201234</li>
<li>DE #4 : 10000</li>
<li>DE #7 : 1107221830</li>
<li>DE #11 : 123456</li>
<li>DE #44 : A5DFGR</li>
<li>DE #105 : ABCDEFGHIJ 1234567890</li>
</ul>
<p>Using above value, the data in data elements :</p>
<div id="attachment_238" class="wp-caption aligncenter" style="width: 310px"><a href="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-de2.png"><img class="size-medium wp-image-238" title="ISO8583 - de" src="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-de2-300x77.png" alt="ISO8583 - de" width="300" height="77" /></a><p class="wp-caption-text">ISO8583 - de</p></div>
<p style="text-align: center;">
<p>Based on the type each value will be formatted.</p>
<ul>
<li>a : alpha (including blanks)</li>
<li>n : numeric value</li>
<li>s : special characters</li>
<li> x (no dot) : length is x (fixed)</li>
<li>.x (one dot) :  max length is x (1 digit in front as length info)</li>
<li>..xx (two dot) :  max length is xx (2 digit in front as length info)</li>
<li>&#8230;xxx (three dot) :  max length is xxx (3 digit in front as length info)</li>
</ul>
<h2><strong>ISO Message</strong></h2>
<p>From above examples the whole ISO message will be :</p>
<p style="text-align: center;">0200B2200000001000000000000000800000201234000000010000110722183012345606A5DFGR021ABCDEFGHIJ   1234567890</p>
<p style="text-align: center;"><a href="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-full1.png"><img class="aligncenter size-full wp-image-239" title="ISO8583 - full" src="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-full1.png" alt="ISO8583 - full" width="983" height="88" /></a></p>
<p style="text-align: center;">
<h2>Conclusion</h2>
<p>Ok. This article already long enough <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Actually I always prefer short article, but on this case it&#8217;s cannot be to short.<br />
Anyway, I hope this article is clear enough for you.</p>
<p>Like always, just drop question in the comment if you confused.</p>
<p>Next I will write article about implementing ISO 8583 using JPOS library.</p>


<p>Related posts:<ol><li><a href='http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Build and Parse ISO Message using JPOS library'>Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Build and Parse ISO Message using JPOS library</a></li><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-send-receiving-on-specific-port-with-j2me-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application'>Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application</a></li><li><a href='http://jimmod.com/blog/2010/04/basic-lwuit-tutorial-with-eclipse-pulsar/' rel='bookmark' title='Permanent Link: Basic LWUIT tutorial/sample with Eclipse Pulsar'>Basic LWUIT tutorial/sample with Eclipse Pulsar</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Jimmy&#8217;s Blog &#8211; Slide Number Puzzle Game with Echo2 Framework</title>
		<link>http://jimmod.com/blog/2011/02/jimmys-blog-slide-number-puzzle-game-with-echo2-framework/</link>
		<comments>http://jimmod.com/blog/2011/02/jimmys-blog-slide-number-puzzle-game-with-echo2-framework/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 06:12:32 +0000</pubDate>
		<dc:creator>jimmy</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[echo2]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[puzzle]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://jimmod.com/blog/?p=193</guid>
		<description><![CDATA[I&#8217;m checking Echo2 framework these couple days and try to make a simple game just to get to know the framework better.
Since I&#8217;m not a JavaScript expert it&#8217;s good to know that there&#8217;s framework that I can use to create AJAX web app with desktop feel easily.
The game is about re-ordering number by moving number [...]


Related posts:<ol><li><a href='http://jimmod.com/blog/2012/07/jimmys-blog-ab-slide-puzzle-for-android/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; AB Slide Puzzle for Android'>Jimmy&#8217;s Blog &#8211; AB Slide Puzzle for Android</a></li><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-send-receiving-on-specific-port-with-j2me-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application'>Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application</a></li><li><a href='http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Build and Parse ISO Message using JPOS library'>Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Build and Parse ISO Message using JPOS library</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m checking Echo2 framework these couple days and try to make a simple game just to get to know the framework better.<br />
Since I&#8217;m not a JavaScript expert it&#8217;s good to know that there&#8217;s framework that I can use to create AJAX web app with desktop feel easily.<br />
The game is about re-ordering number by moving number to the empty space. It&#8217;s simple and fun, this sample is hardcoded to only support 3&#215;3 size.</p>
<p>I assume you know Java, JSP, Servlet basics.<br />
Download Echo 2 from : <a href="http://echo.nextapp.com/site/echo2/download">Echo2 Website</a><br />
I personally use Eclipse for my IDE.</p>
<p>Step by step:<br />
<span id="more-193"></span><br />
<strong>1. Create web project with your IDE, this should set up your project structure based on IDE you used.</strong><br />
<strong>2. Add Echo 2 library to your build path (Echo2_App.jar, Echo2_WebContainer.jar, Echo2_WebRender.jar).</strong><br />
<strong>3. Add servlet mapping in your web.xml</strong></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;display-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>NumberGameServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/display-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>NumberGameServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>gnu.jimmy.java.echo2.numbergame.NumberGameServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>NumberGameServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/game<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><strong>4. Create NumberGameServlet that extend WebContainerServlet. This class will only return the application instance to be displayed to user</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">gnu.jimmy.java.echo2.numbergame</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.app.ApplicationInstance</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.webcontainer.WebContainerServlet</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Servlet implementation class NumberGameServlet
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> NumberGameServlet <span style="color: #000000; font-weight: bold;">extends</span> WebContainerServlet <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span> serialVersionUID <span style="color: #339933;">=</span> 1L<span style="color: #339933;">;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> ApplicationInstance newApplicationInstance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> NumberGameApp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>5. Create class NumberGameApp that extend ApplicationInstance.</strong><br />
This is the core of the game, the game code is simple &#8211; we store the number position data and allow user to switch between number with button up/down/left/right or click the button near the empty one.<br />
After that there will be checking if the number is order properly.<br />
There&#8217;s also button to random the numbers, this will trigger up/down/left/right movements.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">gnu.jimmy.java.echo2.numbergame</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.app.ApplicationInstance</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.app.Button</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.app.Color</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.app.ContentPane</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.app.Extent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.app.Grid</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.app.ImageReference</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.app.Label</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.app.ResourceImageReference</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.app.Window</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.app.WindowPane</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.app.event.ActionEvent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.app.event.ActionListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nextapp.echo2.app.layout.GridLayoutData</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> NumberGameApp <span style="color: #000000; font-weight: bold;">extends</span> ApplicationInstance <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">ActionListener</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Window</span> window<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> ContentPane contentPane<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> Grid container<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Button</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> numbers <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Button</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Button</span> random<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Button</span> up<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Button</span> left<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Button</span> right<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Button</span> down<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> WindowPane pane<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Label</span> paneLabel<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> numberData <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> numberPos <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Window</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		window <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Window</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		contentPane <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ContentPane<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		window.<span style="color: #006633;">setContent</span><span style="color: #009900;">&#40;</span>contentPane<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		container <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Grid<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		container.<span style="color: #006633;">setSize</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		contentPane.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>container<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>numbers.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			ImageReference image <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ResourceImageReference<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;image/&quot;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;.png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			numbers<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Button</span><span style="color: #009900;">&#40;</span>image<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			GridLayoutData layoutData <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GridLayoutData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			layoutData.<span style="color: #006633;">setBackground</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Color</span><span style="color: #009900;">&#40;</span>0xffffcf<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			numbers<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">setLayoutData</span><span style="color: #009900;">&#40;</span>layoutData<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			numbers<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			numberData<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span>
			numberPos<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		random <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Button</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ResourceImageReference<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;image/b_random.png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		random.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		up <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Button</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ResourceImageReference<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;image/b_up.png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		up.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		down <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Button</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ResourceImageReference<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;image/b_down.png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		down.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		left <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Button</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ResourceImageReference<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;image/b_left.png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		left.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		right <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Button</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ResourceImageReference<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;image/b_right.png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		right.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		pane <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WindowPane<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Message&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> Extent<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">200</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> Extent<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		paneLabel <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Label</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pane.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>paneLabel<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pane.<span style="color: #006633;">setModal</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		imageRefresh<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> window<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> switchNumber<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> n1, <span style="color: #000066; font-weight: bold;">int</span> n2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Switching : &quot;</span> <span style="color: #339933;">+</span> n1 <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; - &quot;</span> <span style="color: #339933;">+</span> n2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> t <span style="color: #339933;">=</span> numberData<span style="color: #009900;">&#91;</span>n1<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		numberData<span style="color: #009900;">&#91;</span>n1<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> numberData<span style="color: #009900;">&#91;</span>n2<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		numberData<span style="color: #009900;">&#91;</span>n2<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> t<span style="color: #339933;">;</span>
		numberPos<span style="color: #009900;">&#91;</span>numberData<span style="color: #009900;">&#91;</span>n1<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span>n1<span style="color: #339933;">;</span>
		numberPos<span style="color: #009900;">&#91;</span>numberData<span style="color: #009900;">&#91;</span>n2<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span>n2<span style="color: #339933;">;</span>
		imageRefresh<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> imageRefresh<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		container.<span style="color: #006633;">removeAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>numbers.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			container.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>numbers<span style="color: #009900;">&#91;</span>numberData<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		ImageReference imgEmpty <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ResourceImageReference<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;image/empty.png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		container.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Label</span><span style="color: #009900;">&#40;</span>imgEmpty<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		container.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Label</span><span style="color: #009900;">&#40;</span>imgEmpty<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		container.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Label</span><span style="color: #009900;">&#40;</span>imgEmpty<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		container.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Label</span><span style="color: #009900;">&#40;</span>imgEmpty<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		container.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>up<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		container.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Label</span><span style="color: #009900;">&#40;</span>imgEmpty<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		container.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>left<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		container.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>random<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		container.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>right<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		container.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Label</span><span style="color: #009900;">&#40;</span>imgEmpty<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		container.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>down<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		container.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Label</span><span style="color: #009900;">&#40;</span>imgEmpty<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span><span style="color: #003399;">ActionEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">int</span> numberPress<span style="color: #339933;">=-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getSource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> up<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			moveUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getSource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> down<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			moveDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getSource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> left<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			moveLeft<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getSource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> right<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			moveRight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getSource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> random<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">int</span> total <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Math</span>.<span style="color: #006633;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>total<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">int</span> move <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Math</span>.<span style="color: #006633;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>move<span style="color: #339933;">%</span>4 <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					moveUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>move<span style="color: #339933;">%</span>4 <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					moveDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>move<span style="color: #339933;">%</span>4 <span style="color: #339933;">==</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					moveLeft<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>move<span style="color: #339933;">%</span>4 <span style="color: #339933;">==</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					moveRight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">9</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				 <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getSource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> numbers<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					 numberPress<span style="color: #339933;">=</span>numberPos<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
				 <span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>numberPress<span style="color: #339933;">==</span>numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				moveDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>numberPress<span style="color: #339933;">==</span>numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				moveUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>numberPress<span style="color: #339933;">==</span>numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				moveRight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>numberPress<span style="color: #339933;">==</span>numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				moveLeft<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>checking<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			contentPane.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>pane<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			pane.<span style="color: #006633;">setPositionX</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Extent<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			pane.<span style="color: #006633;">setPositionY</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Extent<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			paneLabel.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Puzzle Finished&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			paneLabel.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> moveUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&lt;=</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			switchNumber<span style="color: #009900;">&#40;</span>numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span>, numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> moveDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&gt;=</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
			switchNumber<span style="color: #009900;">&#40;</span>numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span>, numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> moveLeft<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">%</span>3 <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
			switchNumber<span style="color: #009900;">&#40;</span>numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span>, numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> moveRight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">%</span>3 <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
			switchNumber<span style="color: #009900;">&#40;</span>numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span>, numberPos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">boolean</span> checking<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">boolean</span> match<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">9</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>numberData<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">!=</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				match<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> match<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Screenshot:<br />
<div id="attachment_198" class="wp-caption aligncenter" style="width: 149px"><a href="http://jimmod.com/blog/wp-content/uploads/2011/02/numbergame.png"><img src="http://jimmod.com/blog/wp-content/uploads/2011/02/numbergame-139x300.png" alt="Game Screenshot" title="numbergame" width="139" height="300" class="size-medium wp-image-198" /></a><p class="wp-caption-text">Game Screenshot</p></div></p>
<p>Code logic:<br />
- I create all number using button and add action listener on it.<br />
- On number button clicked it will check if the number is next to empty space, if yes it will switch it.<br />
- Random button will random the movement from 10-110 movement, so the numbers will be disordered but for sure it can be re-ordered.<br />
- Arrow will make empty space switch with number next to it<br />
- After every movement it will check if the numbers already ordered properly</p>
<p>Any question just drop a comment <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>


<p>Related posts:<ol><li><a href='http://jimmod.com/blog/2012/07/jimmys-blog-ab-slide-puzzle-for-android/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; AB Slide Puzzle for Android'>Jimmy&#8217;s Blog &#8211; AB Slide Puzzle for Android</a></li><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-send-receiving-on-specific-port-with-j2me-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application'>Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application</a></li><li><a href='http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Build and Parse ISO Message using JPOS library'>Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Build and Parse ISO Message using JPOS library</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://jimmod.com/blog/2011/02/jimmys-blog-slide-number-puzzle-game-with-echo2-framework/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Jimmy&#8217;s Blog &#8211; Send &amp; Receiving SMS on specific Port with J2ME Application</title>
		<link>http://jimmod.com/blog/2011/02/jimmys-blog-send-receiving-on-specific-port-with-j2me-application/</link>
		<comments>http://jimmod.com/blog/2011/02/jimmys-blog-send-receiving-on-specific-port-with-j2me-application/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 04:19:58 +0000</pubDate>
		<dc:creator>jimmy</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[j2me]]></category>
		<category><![CDATA[jsr-120]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[receive]]></category>
		<category><![CDATA[send]]></category>
		<category><![CDATA[sms]]></category>
		<category><![CDATA[wma]]></category>

		<guid isPermaLink="false">http://jimmod.com/blog/?p=180</guid>
		<description><![CDATA[It’s been a while since I write an article, personal and work have been taken my time much lately.
What I will write is not a new things, maybe a lot of article already write this kind of feature. But yesterday I see this kind of project request in freelancer.com so I decide to create a [...]


Related posts:<ol><li><a href='http://jimmod.com/blog/2010/03/java-me-j2me-json-implementation-tutorialsample/' rel='bookmark' title='Permanent Link: Java ME (J2ME) JSON Implementation Tutorial/Sample'>Java ME (J2ME) JSON Implementation Tutorial/Sample</a></li><li><a href='http://jimmod.com/blog/2010/04/basic-lwuit-tutorial-with-eclipse-pulsar/' rel='bookmark' title='Permanent Link: Basic LWUIT tutorial/sample with Eclipse Pulsar'>Basic LWUIT tutorial/sample with Eclipse Pulsar</a></li><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-slide-number-puzzle-game-with-echo2-framework/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Slide Number Puzzle Game with Echo2 Framework'>Jimmy&#8217;s Blog &#8211; Slide Number Puzzle Game with Echo2 Framework</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>It’s been a while since I write an article, personal and work have been taken my time much lately.</p>
<p>What I will write is not a new things, maybe a lot of article already write this kind of feature. But yesterday I see this kind of project request in freelancer.com so I decide to create a simple sample and write an article about it.</p>
<p>Java Mobile (J2ME) application have a capability to send or receive SMS, but the phone need to support JSR-120 (Wireless Messaging API – WMA 1.0) or JSR-205 (WMA 2.0)<br />
How to check if the phone is supporting this? Easy way if the phone’s brand website. For example for Nokia E72 we can see the technical specifications at <a href="http://developer.nokia.com/Devices/Device_specifications/E72/">http://developer.nokia.com/Devices/Device_specifications/E72/</a><br />
If your phone doesn’t have WMA library the application will prompt error (the error can be different from one phone to another)<br />
<span id="more-180"></span><br />
Sending SMS with J2ME is simple, one thing that programmer can forget is about putting it on another thread. To prevent a dead lock on sending, we need to create a thread to execute the sending.<br />
Another thing is we can specifically send the SMS to specific port, which is important in this J2ME case. Because in J2ME we can only listen SMS on specific port (cannot on default port).</p>
<p>The sample is simple, with basic J2ME programming skill you should able to understand it. If you don’t just drop me a comment <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Source code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">poc.jwork.j2me.sendrecvsms</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.io.Connector</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.lcdui.Command</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.lcdui.CommandListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.lcdui.Display</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.lcdui.Displayable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.lcdui.Form</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.lcdui.TextField</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.midlet.MIDlet</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.midlet.MIDletStateChangeException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.wireless.messaging.MessageConnection</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.wireless.messaging.MessageListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.wireless.messaging.TextMessage</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SMSSender <span style="color: #000000; font-weight: bold;">extends</span> MIDlet <span style="color: #000000; font-weight: bold;">implements</span> CommandListener <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> Form formSender <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Form<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SMS Sender&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">TextField</span> tfDestination <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">TextField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Destination&quot;</span>, <span style="color: #0000ff;">&quot;&quot;</span>, <span style="color: #cc66cc;">20</span>, <span style="color: #003399;">TextField</span>.<span style="color: #006633;">PHONENUMBER</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">TextField</span> tfPort <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">TextField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Port&quot;</span>, <span style="color: #0000ff;">&quot;5000&quot;</span>, <span style="color: #cc66cc;">6</span>, <span style="color: #003399;">TextField</span>.<span style="color: #006633;">NUMERIC</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">TextField</span> tfMessage <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">TextField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Message&quot;</span>, <span style="color: #0000ff;">&quot;message&quot;</span>, <span style="color: #cc66cc;">150</span>, <span style="color: #003399;">TextField</span>.<span style="color: #006633;">ANY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> Command cmdSend <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Command<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Send&quot;</span>, Command.<span style="color: #006633;">OK</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> Command cmdExit <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Command<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Exit&quot;</span>, Command.<span style="color: #006633;">EXIT</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> Display display<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> SMSSender<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		formSender.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>tfDestination<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		formSender.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>tfPort<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		formSender.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>tfMessage<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		formSender.<span style="color: #006633;">addCommand</span><span style="color: #009900;">&#40;</span>cmdSend<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		formSender.<span style="color: #006633;">addCommand</span><span style="color: #009900;">&#40;</span>cmdExit<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		formSender.<span style="color: #006633;">setCommandListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		display <span style="color: #339933;">=</span> Display.<span style="color: #006633;">getDisplay</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> destroyApp<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">boolean</span> arg0<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> MIDletStateChangeException <span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> pauseApp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> startApp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> MIDletStateChangeException <span style="color: #009900;">&#123;</span>
		display.<span style="color: #006633;">setCurrent</span><span style="color: #009900;">&#40;</span>formSender<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> commandAction<span style="color: #009900;">&#40;</span>Command c, Displayable d<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c<span style="color: #339933;">==</span>cmdSend<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			SendMessage.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>tfDestination.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, tfPort.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, tfMessage.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c<span style="color: #339933;">==</span>cmdExit<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			notifyDestroyed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> SendMessage <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> execute<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> destination, <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> port, <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #003399;">Thread</span> thread <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Thread</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Runnable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				MessageConnection msgConnection<span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
					msgConnection <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>MessageConnection<span style="color: #009900;">&#41;</span>Connector.<span style="color: #006633;">open</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sms://&quot;</span><span style="color: #339933;">+</span>destination<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;:&quot;</span> <span style="color: #339933;">+</span> port<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					TextMessage textMessage <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>TextMessage<span style="color: #009900;">&#41;</span>msgConnection.<span style="color: #006633;">newMessage</span><span style="color: #009900;">&#40;</span>
							MessageConnection.<span style="color: #006633;">TEXT_MESSAGE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					textMessage.<span style="color: #006633;">setPayloadText</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					msgConnection.<span style="color: #006633;">send</span><span style="color: #009900;">&#40;</span>textMessage<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					msgConnection.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		thread.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">poc.jwork.j2me.sendrecvsms</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.InterruptedIOException</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.io.Connector</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.lcdui.Command</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.lcdui.CommandListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.lcdui.Display</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.lcdui.Displayable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.lcdui.Form</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.lcdui.TextField</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.midlet.MIDlet</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.microedition.midlet.MIDletStateChangeException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.wireless.messaging.Message</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.wireless.messaging.MessageConnection</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.wireless.messaging.MessageListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.wireless.messaging.TextMessage</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SMSReceiver <span style="color: #000000; font-weight: bold;">extends</span> MIDlet <span style="color: #000000; font-weight: bold;">implements</span> CommandListener, MessageListener <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> Form formReceiver <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Form<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SMS Receiver&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">TextField</span> tfPort <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">TextField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Port&quot;</span>, <span style="color: #0000ff;">&quot;5000&quot;</span>, <span style="color: #cc66cc;">6</span>, <span style="color: #003399;">TextField</span>.<span style="color: #006633;">NUMERIC</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> Command cmdListen <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Command<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Listen&quot;</span>, Command.<span style="color: #006633;">OK</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> Command cmdExit <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Command<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Exit&quot;</span>, Command.<span style="color: #006633;">EXIT</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> Display display<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> SMSReceiver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		formReceiver.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>tfPort<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		formReceiver.<span style="color: #006633;">addCommand</span><span style="color: #009900;">&#40;</span>cmdListen<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		formReceiver.<span style="color: #006633;">addCommand</span><span style="color: #009900;">&#40;</span>cmdExit<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		formReceiver.<span style="color: #006633;">setCommandListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		display <span style="color: #339933;">=</span> Display.<span style="color: #006633;">getDisplay</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> destroyApp<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">boolean</span> unconditional<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> MIDletStateChangeException <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> pauseApp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> startApp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> MIDletStateChangeException <span style="color: #009900;">&#123;</span>
		display.<span style="color: #006633;">setCurrent</span><span style="color: #009900;">&#40;</span>formReceiver<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> commandAction<span style="color: #009900;">&#40;</span>Command c, Displayable d<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c<span style="color: #339933;">==</span>cmdListen<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			ListenSMS sms <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ListenSMS<span style="color: #009900;">&#40;</span>tfPort.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			sms.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			formReceiver.<span style="color: #006633;">removeCommand</span><span style="color: #009900;">&#40;</span>cmdListen<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c<span style="color: #339933;">==</span>cmdExit<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			notifyDestroyed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> notifyIncomingMessage<span style="color: #009900;">&#40;</span>MessageConnection conn<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		Message message<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			message <span style="color: #339933;">=</span> conn.<span style="color: #006633;">receive</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>message <span style="color: #000000; font-weight: bold;">instanceof</span> TextMessage<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				TextMessage tMessage <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>TextMessage<span style="color: #009900;">&#41;</span>message<span style="color: #339933;">;</span>
				formReceiver.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Message received : &quot;</span><span style="color: #339933;">+</span>tMessage.<span style="color: #006633;">getPayloadText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				formReceiver.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Unknown Message received<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">InterruptedIOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// TODO Auto-generated catch block</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> ListenSMS <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">Thread</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> MessageConnection msgConnection<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> MessageListener listener<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> port<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ListenSMS<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> port, MessageListener listener<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">port</span> <span style="color: #339933;">=</span> port<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">listener</span> <span style="color: #339933;">=</span> listener<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			msgConnection <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>MessageConnection<span style="color: #009900;">&#41;</span>Connector.<span style="color: #006633;">open</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sms://:&quot;</span> <span style="color: #339933;">+</span> port<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			msgConnection.<span style="color: #006633;">setMessageListener</span><span style="color: #009900;">&#40;</span>listener<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Screenshot:</strong><br />
<div id="attachment_183" class="wp-caption aligncenter" style="width: 233px"><img src="http://jimmod.com/blog/wp-content/uploads/2011/02/smssender-223x300.png" alt="SMS Sender in simulator" title="smssender" width="223" height="300" class="size-medium wp-image-183" /><p class="wp-caption-text">SMS Sender in simulator</p></div><br />
<div id="attachment_184" class="wp-caption aligncenter" style="width: 251px"><img src="http://jimmod.com/blog/wp-content/uploads/2011/02/smsreceiver-241x300.png" alt="SMS Reveiver in Simulator" title="smsreceiver" width="241" height="300" class="size-medium wp-image-184" /><p class="wp-caption-text">SMS Reveiver in Simulator</p></div></p>
<p><strong>Build:</strong><br />
<a href='http://jimmod.com/blog/wp-content/uploads/2011/02/POC_SendRecvSMS.jad'>JAD FILE</a><br />
<a href='http://jimmod.com/blog/wp-content/uploads/2011/02/POC_SendRecvSMS.jar'>JAR FILE</a></p>


<p>Related posts:<ol><li><a href='http://jimmod.com/blog/2010/03/java-me-j2me-json-implementation-tutorialsample/' rel='bookmark' title='Permanent Link: Java ME (J2ME) JSON Implementation Tutorial/Sample'>Java ME (J2ME) JSON Implementation Tutorial/Sample</a></li><li><a href='http://jimmod.com/blog/2010/04/basic-lwuit-tutorial-with-eclipse-pulsar/' rel='bookmark' title='Permanent Link: Basic LWUIT tutorial/sample with Eclipse Pulsar'>Basic LWUIT tutorial/sample with Eclipse Pulsar</a></li><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-slide-number-puzzle-game-with-echo2-framework/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Slide Number Puzzle Game with Echo2 Framework'>Jimmy&#8217;s Blog &#8211; Slide Number Puzzle Game with Echo2 Framework</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://jimmod.com/blog/2011/02/jimmys-blog-send-receiving-on-specific-port-with-j2me-application/feed/</wfw:commentRss>
		<slash:comments>65</slash:comments>
		</item>
	</channel>
</rss>
