<?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>JavaBeat &#187; J2ME</title>
	<atom:link href="http://www.javabeat.net/category/mobile/j2me/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javabeat.net</link>
	<description>Java Technology News</description>
	<lastBuildDate>Sun, 16 Jun 2013 11:17:41 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Java ME and Web services</title>
		<link>http://www.javabeat.net/2011/03/java-me-and-web-services/</link>
		<comments>http://www.javabeat.net/2011/03/java-me-and-web-services/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 13:45:14 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[J2ME]]></category>
		<category><![CDATA[Webservices]]></category>
		<category><![CDATA[WebServices]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=607</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Introduction Java Micro Edition (Java ME) is a platform for running applications on smaller devices such as mobile phones, PDAs etc. These devices have restrictions in terms of Memory and Processing power. Java ME defines various configurations and profiles. Midlets are java applications that operate on Mobile Information Device Profile (MIDP) which is targeted on [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><a id="dd_start"></a><h2>Introduction</h2>
<p>Java Micro Edition (Java ME) is a platform for running applications on smaller devices such as mobile phones, PDAs etc. These devices have restrictions in terms of Memory and Processing power. Java ME defines various configurations and profiles. Midlets are java applications that operate on Mobile Information Device Profile (MIDP) which is targeted on Mobile phones that has limited memory and processing power. If you are new to Java ME please refer to the articles <strong><a href="http://www.javabeat.net/articles/27-introduction-to-j2me-1.html">Introduction to J2ME</a></strong> and <strong><a href="http://www.javabeat.net/articles/45-j2me-user-interface-1.html">J2ME User Interface</a></strong> in Java Beat.</p>
<p>Due to the limitations on the mobile phones, the midlets can’t be exposed as a web service. But the midlets can consume web services. Java ME provides a subset of JAX-RPC APIs to work with web services. This article will provide a step by step procedure to access web services from a midlet.</p>
<h2>Invoking web services from a Midlet</h2>
<p>To access web services, the Midlet has to make remote calls on the web services. But the Midlets won’t do this directly. A stub has to be created and calls are made via the stub instance. Using wireless toolkit it is made very simple to create stub code. Invocation on web service method is a synchrous process. The parameters for the methods are passes by value instead of pass by references. Similarly the values are returned by web services as pass by value. On the stubs midlets can set some properties like USERNAME_PROPERTY, PASSWORD_PROPERTY (User name and password for authentication), ENDPOINT_ADDRESS_PROPERTY(Address of the endpoint) and SESSION_MAINTAIN_PROPERTY(if true:session will be maintained between endpoint and midlet) using _setProperty method.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY,serviceUrl);
	stub._setProperty(Stub.SESSION_MAINTAIN_PROPERTY, new Boolean(true));</pre></td></tr></table></div>

<p>The generated stub code and the supportive classes have to be bundled in the jar file along with the midlet. While accessing web services the best practice is to write the sub invocation code in a seperate thread. This will avoid your application hanging as your thread will be blocked during web service invocation.</p>
<h2>Example</h2>
<p>This example will help you in understanding how to access web service from a midlet. Netbeans IDE, Glassfish application server and Wireless tool kit 2.5.2 are used.</p>
<h3>Create the web service and deploy it in the application server</h3>
<p><span style="text-decoration: underline;">Web service:</span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">package mypack;
	import javax.jws.WebMethod;
	import javax.jws.WebParam;
	import javax.jws.WebService;
	@WebService()
	public class HelloService {
		@WebMethod(operationName = &quot;getMessage&quot;)
		public String getMessage(@WebParam(name = &quot;name&quot;)
		String name) {
			return &quot;Hi &quot;+name+&quot;! Welcome to JME Programming&quot;;
		}
	}</pre></td></tr></table></div>

<p><span style="text-decoration: underline;">WSDL URL:</span></p>
<p>http://localhost:17754/HelloWebService/HelloServiceService?WSDL</p>
<h3>Create a Midlet with a form with a text field and command buttons.</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public class Midlet extends MIDlet implements CommandListener{
		private Form myform;
		private TextField field;
		private Command exit,getMessage;
		private Display d;
		public void startApp() {
			d=Display.getDisplay(this);
			myform=new Form(&quot;Access Webservice&quot;);
			field=new TextField(&quot;Name&quot;, &quot;&quot;, 20, TextField.PLAIN);
			exit=new Command(&quot;Exit&quot;, Command.EXIT, 0);
			getMessage=new Command(&quot;GetMsg&quot;, Command.SCREEN, 1);
			myform.append(field);
			myform.addCommand(exit);
			myform.addCommand(getMessage);
			myform.setCommandListener(this);
			d.setCurrent(myform);
		}
		public void pauseApp() {
		}
		public void destroyApp(boolean unconditional) {
		}
		public void commandAction(Command c, Displayable d) {
			if(c==exit){
				notifyDestroyed();
			}else if(c==getMessage){
				//Code to Access Webservice
			}
		}
	}</pre></td></tr></table></div>

<h3>Use Wireless tool kit tool to create the stub</h3>
<p><a href="http://www.javabeat.net/wp-content/uploads/2011/03/113.jpg"><img class="aligncenter size-medium wp-image-1110" title="1" src="http://www.javabeat.net/wp-content/uploads/2011/03/113-300x168.jpg" alt="" width="300" height="168" /></a>a) Open Wireless Toolkit</p>
<p><center></center><a href="http://www.javabeat.net/wp-content/uploads/2011/03/210.jpg"><img class="aligncenter size-medium wp-image-1111" title="2" src="http://www.javabeat.net/wp-content/uploads/2011/03/210-300x167.jpg" alt="" width="300" height="167" /></a></p>
<p>(b) Select File -&gt; Utilities</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2011/03/35.jpg"><img class="aligncenter size-medium wp-image-1307" title="3" src="http://www.javabeat.net/wp-content/uploads/2011/03/35-300x256.jpg" alt="" width="300" height="256" /></a></p>
<p><center></center>(c) Select Stub Generator</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2011/03/45.jpg"><img class="aligncenter size-medium wp-image-1306" title="4" src="http://www.javabeat.net/wp-content/uploads/2011/03/45-279x300.jpg" alt="" width="279" height="300" /></a></p>
<p><center></center>d) Provide WSDL URL and the Output folder(src folder in Netbeans project) and the package details. Click on Ok</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2011/03/52.jpg"><img class="aligncenter size-medium wp-image-1108" title="5" src="http://www.javabeat.net/wp-content/uploads/2011/03/52-300x210.jpg" alt="" width="300" height="210" /></a></p>
<p><center></center>(e) The Stub and the other classes are generated in the src folder</p>
<h3>Access Web service</h3>
<p>For accessing web service,</p>
<ol>
<li>Create a new thread.</li>
<li>In the new thread, Instantiate the stub</li>
<li>Set properties on the stub if required</li>
<li>Invoke the web service methods on the stub</li>
</ol>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">//Extend the code written earlier
	import mypack.HelloService_Stub;
	public class Midlet extends MIDlet implements CommandListener{
		private Form myform;
		private TextField field;
		private Command exit,getMessage;
		private Display d;
		public TextField getField() {
			return field;
		}
		public Form getMyform() {
			return myform;
		}
		....
		public void commandAction(Command c, Displayable d) {
			if(c==exit){
				notifyDestroyed();
			}else if(c==getMessage){
				Thread t=new Thread(new NewThread(this));
				t.start();
			}
		}
	}	
	class NewThread implements Runnable{
		Midlet m;
		NewThread(Midlet m){
			this.m=m;
		}
		public void run() {
			Form frm=m.getMyform();
			TextField txt=m.getField();
			HelloService_Stub stub=new HelloService_Stub();
			String msg=&quot;&quot;;
			try {
				msg = stub.getMessage(txt.getString());
				frm.append(msg);
			} catch (RemoteException ex) {
				frm.append(ex.getMessage());
			}
		}
	}</pre></td></tr></table></div>

<h3>Run the Midlet</h3>
<p>Run the midlet. Provide the Name and select the command button GetMsg. The following output will be displayed.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2011/03/6.jpg"><img class="aligncenter size-medium wp-image-1308" title="6" src="http://www.javabeat.net/wp-content/uploads/2011/03/6-147x300.jpg" alt="" width="147" height="300" /></a></p>
<h2>Conclusion</h2>
<p>Java ME Midlets can act only as the consumer for web services. It can’t be exposed as a web service. Wireless Tool Kit helps in creating stubs for web services. Midlets by invoking methods on the stub invokes methods on web services. Both simple types and complex types can be passed as parameters to the web services.</p>
<div class='dd_outer'><div class='dd_inner'><div id='dd_ajax_float'><div class='dd_button_v'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Fwww.javabeat.net%2Fcategory%2Fmobile%2Fj2me%2Ffeed%2F" send="false" show_faces="false"  layout="box_count" width="50"  ></fb:like></div><div style='clear:left'></div><div class='dd_button_v'><script type='text/javascript' src='https://apis.google.com/js/plusone.js'></script><g:plusone size='tall' href='http://www.javabeat.net/category/mobile/j2me/feed/'></g:plusone></div><div style='clear:left'></div><div class='dd_button_v'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.javabeat.net/category/mobile/j2me/feed/" data-count="vertical" data-text="J2ME" data-via="javabeat" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style='clear:left'></div><div class='dd_button_extra_v'><script type="text/javascript">jQuery(document).load(function(){ stLight.options({publisher:'bab47279-62c9-46af-addc-79fd1fe8fee0'}); });</script><div class="st_email_custom"><span id='dd_email_text'>email</span></div></div><div style='clear:left'></div><div class='dd_button_extra_v'><div id='dd_print_button'><span id='dd_print_text'><a href='javascript:window:print()'>print</a></span></div></div><div style='clear:left'></div></div></div></div><script type="text/javascript">var dd_offset_from_content = 44; var dd_top_offset_from_content = 0;</script><script type="text/javascript" src="http://www.javabeat.net/wp-content/plugins/digg-digg//js/diggdigg-floating-bar.js?ver=5.3.0"></script><div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2011/03/java-me-and-web-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing JSF applications for J2ME clients</title>
		<link>http://www.javabeat.net/2010/10/writing-jsf-applications-for-j2me-clients/</link>
		<comments>http://www.javabeat.net/2010/10/writing-jsf-applications-for-j2me-clients/#comments</comments>
		<pubDate>Tue, 26 Oct 2010 01:19:57 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[J2ME]]></category>
		<category><![CDATA[Java Server Faces (JSF)]]></category>
		<category><![CDATA[JSF]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=514</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Introduction JSF is a Web framework for developing Component oriented web applications in the User Interface layer. Amongst the various capabilities that JSF provides, one of the major strengths of JSF is that it is not tied to any specific target device. For example, currently most of the JSF applications are running in a web [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2>Introduction</h2>
<p align="justify"><a href="http://www.javabeat.net/articles/11-introduction-to-java-server-faces-1.html">JSF</a> is a Web framework for developing Component oriented web applications in the User Interface layer. Amongst the various capabilities that JSF provides, one of the major strengths of JSF is that it is not tied to any specific target device. For example, currently most of the JSF applications are running in a web server and are accessible through a web browser. However, web browser is not the only target for a JSF application to be viewed; it can be even accessed through a hand-held device, for example through a mobile phone. In this example, we will see how to develop JSF applications targeted for mobile phones. This article assumes that the reader has a good understanding of <strong>JSF</strong>, its life-cycle and some understanding on <strong>JSF</strong> renderer kits.</p>
<h2>Download Sample Code for JSF Application for J2ME Clients</h2>
<ul>
<li><a href="http://www.javabeat.net/articles/sourcecode/2010/201010-jsf-applications-for-j2me-clients.zip">Download Sample Code for JSF Application for J2ME Clients</a></li>
</ul>
<h2>Renderer kits</h2>
<p align="justify">The responsibility of displaying a view in a target device is done through renderer kits. Renderer kits in <strong>JSF</strong> are nicely abstracted so it is possible to write custom implementation of renderer kits. Sun&#8217;s implementation of <strong>JSF</strong> provides a reference implementation of a HTML renderer kit. The HTML renderer kit is responsible for displaying the view in a web browser. So while writing a renderer kit implementation amongst the various factors to be taken into consideration, the important things are the target device, the protocol, the markup language and the scripting language. For a HTML renderer kit implementation, these would be the Web browsers, HTTP, hyper text markup language and java script.</p>
<p align="justify">Similarly a render kit implementation would consider the mobile phone browser, Wireless application protocol, the Wireless markup language (WML) and WML Script for providing suitable support in the mobile or any WAP browser. Wireless application protocol is the standard defined for displaying contents on wireless devices such as mobile phones. Similar to HTML that targets Web browsers, WML is the markup language for mobile phones. Consider the sample WML script,</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;!DOCTYPE wml PUBLIC &quot;-//WAPFORUM//DTD WML 1.1//EN&quot;
   &quot;http://www.wapforum.org/DTD/wml_1.1.xml&quot; &gt;
&lt;wml&gt;
	&lt;card id=&quot;test&quot; title=&quot;Test card&quot;&gt;
		&lt;p&gt;This is a test WML page.&lt;/p&gt;
	&lt;/card&gt;
&lt;/wml&gt;</pre></td></tr></table></div>

<p align="justify">Usually WML document can be thought of as a collection of cards. Each user interaction will be modeled as a card and each card will be inter-dependant. The syntax will mostly look like HTML for displaying the UI elements and content in the WML browser.</p>
<p align="justify">WML script, similar to Java script, is the client side scripting language for WML. It is mainly used for dynamically validating user input and it generally will appear in a separate file. Consider the following example script,</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">extern function sayHello()
{
	WMLBrowser.setVar(&quot;message&quot;, &quot;Hello World.&quot;);
	WMLBrowser.refresh();
}</pre></td></tr></table></div>

<p align="justify">The above script will appear in a separate file, say &#8216;hello.wmls&#8217; and the following wml page will provide a reference to the above wml script.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;!DOCTYPE wml PUBLIC &quot;-//WAPFORUM//DTD WML 1.1//EN&quot;
   &quot;http://www.wapforum.org/DTD/wml_1.1.xml&quot; &gt;
&lt;wml&gt;
	&lt;card id=&quot;test&quot; title=&quot;Test card&quot;&gt;
		&lt;p&gt;&lt;a href=&quot;hello.wmls#sayHello()&quot;&gt;Run&lt;/a&gt;&lt;br/&gt;
		$(message)
		&lt;/p&gt;
	&lt;/card&gt;
&lt;/wml&gt;</pre></td></tr></table></div>

<h3>Mobile Faces</h3>
<p align="justify">Mobile Faces for <strong>JSF</strong> provides a framework for simplifying the development of <strong>JSF</strong> applications targeted for wireless devices. The framework comes packaged with an implementation of renderer kits for HTML, XHTML-MP and WML. Also it supports various commonly used scripting languages such as Java Script, WML Script and ECMA Script. For testing <strong>JSF</strong> faces developed through Mobile Faces framework, we will be using OpenWave Browser for WAP. It serves as an emulator for testing WAP applications. In this article, we will be showing how to develop applications using the Mobile Faces toolkit.</p>
<h3>Setting up the development environment</h3>
<p align="justify">Download the following components before proceeding to the next section.</p>
<ul>
<li><a href="http://wapreview.com/download/Openwave_v70_Simulator.exe">Open Wave</a></li>
<li><a href="https://mobilejsf.dev.java.net">Mobile Faces</a></li>
</ul>
<p align="justify">OpenWave is used for testing the <strong>JSF</strong> application in the WAP Browser. Mobile Faces distribution has to be downloaded, jar file has to be built from the distribution&#8217;s ant file and the same has to be made available in the application&#8217;s class path.</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/10/writing-jsf-applications-for-j2me-clients/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>J2ME User Interface</title>
		<link>http://www.javabeat.net/2007/10/j2me-user-interface/</link>
		<comments>http://www.javabeat.net/2007/10/j2me-user-interface/#comments</comments>
		<pubDate>Sat, 20 Oct 2007 11:48:17 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[J2ME]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=124</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>1) Introduction User-interface requirements for small handheld devices are different from personal computers. Because comparatively the display size of handheld devices is smaller. That’s why, we cannot follow the personal computers user-interface programming guidelines for handheld devices. In J2ME,the CLDC itself does not define any GUI functionality. The official GUI classes for the J2ME are [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2><span style="font-family: Verdana;">1) Introduction</span></h2>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;"><strong>User-interface</strong> requirements for small handheld devices are different from personal computers. Because comparatively the <strong>display size</strong> of handheld devices is smaller. That’s why, we cannot follow the personal computers user-interface programming guidelines for handheld devices. In J2ME,the <strong>CLDC</strong> itself does not define any GUI functionality. The official GUI classes for the J2ME are included in profiles such as the <strong>MIDP</strong> and are defined by the <strong>Java Community Process (JCP)</strong>. The GUI classes in the MIDP are not based on the <strong>Abstract Window Toolkit (AWT)</strong>. The <strong>limited CPU memory</strong> of handheld devices, cannot handle the AWT. The <strong>MIDP contains its own GUI</strong> guidelines. The MIDP GUI consists of <strong>high-level and low-level APIs</strong>, each with their own set of events. Here we are going to discuss about only High-level API’s.</span></p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">Contents: (This one itself shows the <strong>Device Display Heirarchy</strong>)</span></p>
<p align="justify">
<ul>
<li>Display Object
<ul>
<li>Displayable Object</li>
</ul>
</li>
<li>DISPLAYABLE : Screen Object
<ul>
<li>TextBox Object</li>
<li>Alert Object</li>
<li>List Object</li>
<li>Form Object</li>
</ul>
</li>
<li>FORM : Item Object
<ul>
<li>ChoiceGroup Object</li>
<li>DateField Object</li>
<li>Guage Object</li>
<li>Image and ImageItem Object</li>
<li>StringItem Object</li>
<li>TextField Object</li>
</ul>
</li>
</ul>
<p>&nbsp;</p>
<h2><span style="font-family: Verdana;">2) API&#8217;s</span></h2>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">MIDP offers a <strong>high-level API</strong> objects for user interface development. This is used to build <strong>common user-interface</strong> components such as Form s, TextBox etc&#8230; This handles most component functionality, such as <strong>drawing each component on the screen</strong>.</span></p>
<h3><span style="font-family: Verdana;">2.1) Display Object</span></h3>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">A <strong>MIDlet</strong> has one instance of a <strong>Display</strong> object. This object is used to obtain information about the <strong>current display</strong> and includes methods for requesting the objects being displayed. The <strong>Display object</strong> is essentially the <strong>manager of the device display</strong>.<strong>Display</strong> is represented by the <strong>javax.microedition.lcdui.Display</strong> class. The Display class is the one and only display manager that is instantiated for each active MIDlet and provides methods to retrieve information about the device’s display capabilities.A reference to the device’s display can be obtained by providing a MIDlet reference to the static <strong>getDisplay( )</strong> method in the <strong>startApp( )</strong> method of a MIDlet.</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public Display getDisplay(MIDlet lMidlet);		
&nbsp;
&nbsp;
public class firstMidlet extends MIDlet
 {
	firstMidlet( ) { }
	int startApp( ) 
	{ .....
		return 0;}	
}</pre></td></tr></table></div>

<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">Now we have a reference. Then we have to create <strong>GUI component</strong>. The two forms of the <strong>setCurrent()</strong> method with this reference as parameter are shown here.</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">setCurrent(Displayable dispRef);
setCurrent(Alert aRef, Displayable dispRef);</pre></td></tr></table></div>

<h4><span style="font-family: Verdana;">2.1.1) Displayable Object</span></h4>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">There is only <strong>one Display object</strong> per MIDlet, but many objects within a MIDlet may be <strong>displayable</strong>. A <strong>Displayable object</strong> is a component that is <strong>visible on a device</strong>. MIDP contains <strong>two subclasses of Displayable: Screen and Canvas</strong>.</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">abstract public class Displayable
public abstract class Canvas extends Displayable
public abstract class Screen extends Displayable</pre></td></tr></table></div>

<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">We can find out that, what is currently being displayed on the device. We can find the types of colors the display object supports.Here are the methods.</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public Displayable getCurrent( );
&nbsp;
public void boolean isColor( ); //returns TRUE if it supports Color, FALSE if it Supports grayscale
public int numColors( ); //Returns number of colors it supports</pre></td></tr></table></div>

<p>&nbsp;</p>
<h3><span style="font-family: Verdana;">2.2) DISPLAYABLE : Screen Object</span></h3>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">User interacts with the device through <strong>Screen</strong>. <strong>Screen</strong> <strong>combines and organizes graphics objects</strong> and <strong>manages user input</strong> through the device. <strong>Screens</strong> are represented by the <strong>javax.microedition.lcdui.Screen</strong> object. Then by calling <strong>setCurrent( )</strong> they will shown by the <strong>Display</strong> object.There can be several screens in an application, but only one screen at a time can be visible in a display. There are <strong>four types of screens</strong>, <strong>TextBox, List, Alert, and Form</strong>. Screen can have two characteristics: <strong>title and ticker</strong>. </span></p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;"><br />
<!--?php include("http://www.javabeat.net/articles/templates/article_banner_middle.php"); ?--><br />
The <strong>title</strong> is a <strong>string that appears above</strong> the screen contents. The following methods are used to <strong>set and retrieve the title </strong> of the screen.</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public void setTitle(String title);
public String getTitle( );</pre></td></tr></table></div>

<p>&nbsp;</p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">The <strong>Ticker</strong> is a <strong>image that stays above the title</strong>. The <strong>Ticker</strong> class implements a <strong>tickertape</strong>. <strong>Starting and Stopping</strong> the Ticker doesn&#8217;t done using methods.The string associated with Ticker scrolls continuously, whose direction of scrolling and the speed of the scrolling depends on the <strong>MIDP</strong> implementation.The following are the list of methods used in the <strong>Ticker</strong>.</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public void setTicker(Ticker ticker); // To set the Ticker
public Ticker getTicker( ); // To get the Ticker
&nbsp;
public Ticker(String string); // Ticker's Constructor.
&nbsp;
public String getString( ); //To get the sring Associated with he Ticker
public setString(String s);// To set the sring Associated with he Ticker
&nbsp;
setTicker(new Ticker(&quot;HI HOW ARE YOU&quot;));//To attach the Ticker to screen</pre></td></tr></table></div>

<p>&nbsp;</p>
<h4><span style="font-family: Verdana;">2.2.1) TextBox</span></h4>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;"><strong>TextBox</strong> is a screen&#8217;s object, using which we can give <strong>input and modify</strong> the text. TextBox is used when the user needs to give the input for the application. Here is the TextBox&#8217;s Constructor. </span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public TextBox(String title, String text, int maxSize, int constraints);</pre></td></tr></table></div>

<p>&nbsp;</p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">The <strong>text</strong> is used to get the <strong>text</strong> in the TextBox and <strong>maxSize</strong> is used to set the <strong>maximum size</strong> of the TextBox. Some integer constants are used to limit the text in the TextBox such as TextField.ANY , TextField.EMAILADDR ,TextField.NUMBER, TextField.PASSWD, TextField.PHONENUMBER, and TextField.URL. Here are some methods used with TextBox.</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public int getConstraints( ); // To get the Current Constraints associated with the TextBox
public void setConstraints(int c);// To set the Constraints for TextBox
&nbsp;
public int getMaxSize( ); // To get the Maximum Size of TextBox
public void setMaxSize(int size); // To set the Maximum Size of TextBox
&nbsp;
public String getString( ); // To get the Text in the TextBox
public void setString(String s); // To set the Text in the TextBox
&nbsp;
public int size( ); // To Get the number of Characters in the TextBox
&nbsp;
/* Text Manipulation Methods */
&nbsp;
public void delete(int offset, int length); // To delete some text
public void insert(char[] texts, int offset, int length, int position); // To Insert text
public void replace(String str, int position); // To replace the text
public void setChars(char[] texts, int offset, int length); // To set the characters
&nbsp;
public int getCaretPosition(  ); // To get the Cursors position</pre></td></tr></table></div>

<p>&nbsp;</p>
<h4><span style="font-family: Verdana;">2.2.2) Alert</span></h4>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;"><strong>Alert</strong> is a screen which contains <strong>text or image</strong>. It is used to show the errors and exceptions. A <strong>modal alert</strong> is a alert which need confirmation from user to close it.But the <strong>timed alert</strong> doesnt need the confirmation from user.It shows the error for certain amount of time and terminates.Here is the constructor for Alert:</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public Alert(String name);
public Alert(String name, String message, Image msgImage, AlertType errorType);</pre></td></tr></table></div>

<p>&nbsp;</p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">We can use a timeout value for displaying the Alert message, means how much time the Alert message displays. Initially we can set the timeout and later we can change it. If we want to know the current timeout value we can get it.Similarly we can set and get the Image and String values associated with the Alert.Here are the methods for the same.</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public int getDefaultTimeout( );// To get the current default timeout value
public int getTimeout( );		//To get the current timeout value
public void setTimeout(int t);	//To set the timeout value
Alert alert = new Alert(&quot;Error Message&quot;); // To create a new Alert
alert.setTimeout(5000); 		// Sets the timeout for 5000 milli seconds
alert.setTimeout(Alert.FOREVER); // To display the alert until user closes it.
public Image getImage( ); 		// To get the image associated with the Alert
public String getString( ); 	// To get the String associated with the Alert
public void setImage(Image &quot;alert.png&quot;); //To set the image associated with the Alert
public void setString(String &quot;Spawning Error&quot;); // To set the String associated with the Alert</pre></td></tr></table></div>

<p>&nbsp;</p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">The <strong>AlertType</strong> class has provided with five differet types of alerts: <strong>AlertType.ERROR, AlertType.ALARM, AlertType.CONFIRMATION, AlertType.WARNING, and AlertType.INFO. </strong>. Here are some methods to set and get the Alert Types.</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public AlertType getType( );
public void setType(AlertType AlertType.CONFIRMATION);</pre></td></tr></table></div>

<p>&nbsp;</p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">Similarly we can create specific types of alerts as timedAlert or modalAlert.And using the same methods we can set and get the timeouts for them.</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">Alert timedAlert = new Alert (&quot;Warning&quot;, &quot;Clear It&quot;, null, AlertType.WARNING); // Creating
TimedAlert.setTimeout(5000); // to set the timeout for timedAlert
Display.setCurrent(timedAlert, timed); // To set the timedAlert as current alert
&nbsp;
Alert modalAert = new Alert(&quot;Alarm&quot;, &quot;Reminder&quot;, null, AlertType.ALARM);// Creating
modalAlert.setTimeout(alert.FOREVER); // modalAlert need manual dismissal
display.setCurrent(modalAlert, timed);// To set the modalAlert as current alert</pre></td></tr></table></div>

<p>&nbsp;</p>
<h4><span style="font-family: Verdana;">2.2.3) List</span></h4>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;"><strong>List</strong> is a screen which is having some choices for selection. User has to select one of the choices explicitly. Its constructors are:</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public List(String name, int listType);
public List(String name, int listType, String[] stringElements, Image[] imageElements);</pre></td></tr></table></div>

<p>&nbsp;</p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">There are three types of <strong>list types</strong>, <strong>MULTIPLE , EXCLUSIVE, and IMPLICIT </strong>. </span></p>
<p align="justify">
<ul>
<li><strong>EXCLUSIVE</strong> type of list allows only one selection.</li>
<li><strong>IMPLICIT</strong> type of list is a list where the choice is implicitly selected.</li>
<li><strong>MULTIPLE</strong> type of list allows more than one selection of choices.</li>
</ul>
<p>&nbsp;</p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">Here is an example</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">List list = new List(&quot;select one or more&quot;, Choice.MULTIPLE);</pre></td></tr></table></div>

<p>&nbsp;</p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">We can <strong>append, insert, or replace choices</strong> in the list. For a choice the text associated to it is mandatory and image associated with it is optional. We can delete the index associated t a choice. We can get text and image associated to a choice. Here are the methods:</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public int append(String string, Image image); // To append into the list
public void insert(int choiceNo, String string, Image image); // To insert into the ist
public void set(int choiceNo, String string, Image image);//To replace the choice in the list
&nbsp;
int open = list.append(&quot;OPEN&quot;, null); // open is index for the choice &quot;OPEN&quot;
&nbsp;
public void delete(int index); // To delete an index
&nbsp;
public String getString(int index); // To get the text associated to the choice with its index
public Image getImage(int index);//To get the image associated to the choice with its index
&nbsp;
public boolean isSelected(int index); // To know which is selected in the list
public setSelectedIndex(int index, boolean bool); // To select the choice
&nbsp;
public int getSelectedFlags(boolean[] selectedArray); // To set the selection state of the entire list
public void setSelectedFlags(boolean[] selectedArray); // To modify the one that has been passed in</pre></td></tr></table></div>

<p>&nbsp;</p>
<h4><span style="font-family: Verdana;">2.2.4) Form</span></h4>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;"><strong>Forms</strong> used to <strong>combine multiple components</strong> into one screen. It is a screen that contains items. Its constructors are:</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public Form(String str);
public Form(String str, Item[] items);</pre></td></tr></table></div>

<p>&nbsp;</p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">It will arrange its components as a list. Like the choices within a list, items within a form can be edited using <strong>insert, append, and delete</strong>.Here are some examples.</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public int append(Image img); //appends an object that subclasses the Item object	
public int append(Item item);
public int append(String str); //append a generic string	
public void delete(int itemNum); //deletes the item at the given position
public Item get(int itemNum);//access any item in the form at its given position
public void insert(int itemNum, Item item);//inserts an item in the form
public int set(int itemNum, Item item);//setting the item referenced by itemNum
public int size( );//find the current number of items that are in the form</pre></td></tr></table></div>

<p>&nbsp;</p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">The GUI components that can be placed on a form are: <strong>ChoiceGroup, DateField, Gauge, ImageItem, StringItem, and TextField</strong>.</span></p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2007/10/j2me-user-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to J2ME</title>
		<link>http://www.javabeat.net/2007/07/introduction-to-j2me/</link>
		<comments>http://www.javabeat.net/2007/07/introduction-to-j2me/#comments</comments>
		<pubDate>Fri, 27 Jul 2007 02:00:05 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[J2ME]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=71</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>1) Introduction J2ME (Java 2 Micro Edition) is an advanced technology in Java, developed with the help of Java Community Process Program. J2ME is a reduced version of the Java API and Java Virtual Machine that is designed to operate within the limited resources available in the embedded computers and microcomputers. J2ME is targeted to [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2><span style="font-family: Verdana;">1) Introduction</span></h2>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;"><strong>J2ME (Java 2 Micro Edition)</strong> is an advanced technology in Java, developed with the help of <strong>Java Community Process Program</strong>. J2ME is a reduced version of the Java API and Java Virtual Machine that is designed to operate within the limited resources available in the embedded computers and microcomputers. </span></p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;"><strong>J2ME</strong> is targeted to developers of <strong>intelligent wireless devices and small computing devices</strong> who need to incorporate cross-platform functionality in their products. A key benefit of using <strong>J2ME is compatibility with all Java-enabled devices</strong>. Motorola, Nokia, Panasonic all have Java-enabled devices.A J2ME application is a balance between local and server-side processing. </span></p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">The Java Community Process Program used a two approaches to addressing the needs of small computing devices.</span></p>
<ul>
<li><strong>Configurations:</strong>It is the Java run-time environment and core classes that operate on each device. A configuration defines the Java Virtual Machine for a particular small computing device. There are two configurations.
<ul>
<li><strong>CLDC for handheld devices:</strong>The <strong>CLDC (Connected Limited Device Configuration)</strong> is designed for <strong>16-bit or 32-bit</strong> small computing devices with limited memory. These devices usually have between <strong>160KB and 512KB</strong> of available memory. Usually these are powered by battery. They use small-bandwidth network wireless connection. These devices uses a stripped-down version of the JVM the<strong> KJava Virtual Machine (KVM)</strong>. These devices include <strong>pagers, personal digital assistants, cell phones, dedicated terminals, and handheld consumer device</strong>.</li>
<li><strong>CDC for plug-in devices:</strong><strong>CDC(Connected Device Configuration)</strong> devices use a <strong>32-bit </strong>architecture, have at least <strong>2 MB</strong> of memory available, and implement a complete functional JVM. CDC devices include <strong>digital set-top boxes, home appliances, navigation systems, point-of-sale terminals, and smart phones</strong>.</li>
</ul>
</li>
<li><strong>Profiles:</strong>It is defined for categories of small computing devices. A profile consists of classes that enable developers to implement features found on a related group of small computing devices.List of J2ME Profiles:
<ul>
<li><strong>Profiles Used with CLDC: </strong>
<ul>
<li>Mobile Information Device Profile(MIDP)</li>
<li>PDA Profile(PDAP)</li>
</ul>
</li>
<li><strong>Profiles Used with CDC:</strong>
<ul>
<li>Foundation Profile</li>
<li>Game Profile</li>
<li>Personal Profile</li>
<li>Personal Basis Profile</li>
<li>RMI Profile.</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2><span style="font-family: Verdana;">2)J2ME Architecture</span></h2>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">There are <strong>5 layers in</strong> J2ME Architecture.Those are:</span></p>
<ul>
<li><strong>MIDP (TopMost Layer):</strong> Which contains Java APIs for user network connections, persistence storage, and the user interface. It also has access to CLDC libraries and MIDP libraries.</li>
<li><strong>J2ME API’s(Profiles):</strong> Which consists of the minimum set of application programming interfaces for the small computing device</li>
<li><strong>Configurations:</strong> Which handles interactions between the profile and the JVM.</li>
<li><strong>JVM</strong></li>
<li><strong>Operating System(Bottom Layer).</strong></li>
</ul>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;"><strong>1,2 and 3 are software Layers.</strong> </span></p>
<h2><span style="font-family: Verdana;">3) Midlets.</span></h2>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">A <strong>MIDlet is a J2ME application</strong> which operate on an <strong>MIDP</strong>. A <strong>MIDlet</strong> is defined with <strong>at least a single class</strong> that is derived from the <strong>javax.microedition.midlet.MIDlet abstract class</strong>. Common programming is <strong>grouping related MIDlets into a MIDlet suite</strong>, which is contained within the same package and implemented simultaneously. All <strong>MIDlets within a MIDlet suite</strong> are considered a <strong>group</strong> and must be installed and uninstalled as a group. MIDlets from the same MIDlet suite run the same class. Benefit of the relationship among MIDlet suite members is that they share the same data. </span></p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">A <strong>MIDlet </strong>is an <strong>event-based application</strong>. All routines executed in the MIDlet are invoked in response to an event reported to the MIDlet by the application manager. The initial event that occurs is when the MIDlet is started and the application manager invokes the <strong>startApp()</strong> method. The startApp() method in a typical MIDlet contains a statement that displays a screen of data and prompts the user to enter a selection from among one or more options. The nature and number of options is, MIDlet and screen dependent. A <strong>Command</strong> object is used to present a user with a selection of options to choose from when a screen is displayed. Each screen must have a <strong>CommandListener</strong>. A <strong>CommandListener</strong> monitors user events with a screen and causes the appropriate code to execute based on the current event.</span></p>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">Here we dicuss about <strong>Application Manager Responsibilities</strong> which is running on the device which is provided by the Device manufacturer:</span></p>
<ul>
<li>Installing, executing, and removing a MIDLet Suite.</li>
<li>Giving access to classes of the JVM and CLDC for Each member of the MIDlet suite.</li>
<li>Makes the Java archive (JAR) file and the Java application descriptor (JAD) file available to members of the MIDlet suite.</li>
</ul>
<h3><span style="font-family: Verdana;">3.1) JAR Files</span></h3>
<h5><span style="font-family: Verdana;">3.1.1)Something About Manifest File: </span></h5>
<ul>
<li>Nine attributes are defined in this file.The first <strong>six attributes are necessary</strong>.</li>
<li>The file’s extension is changed to<strong> .mf </strong>when the MIDlet is prepared for deployment.</li>
<li>All entries are name:value pairs.</li>
<li>Each pair must be terminated with a carriage return.</li>
<li>Whitespace between the colon and the attribute value is ignored.</li>
</ul>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">Here are <strong> Necessary Attributes of a Manifest File</strong> : </span></p>
<ul>
<li><strong> MIDlet-Name:</strong> MIDlet suite name.</li>
<li><strong> MIDlet-Version:</strong> MIDlet version number.</li>
<li><strong> MIDlet-Vendor:</strong> Name of the vendor who supplied the MIDlet.</li>
<li><strong> MIDlet-n:</strong> Attribute per MIDlet. Values are MIDlet name, optional icon, and MIDlet class name.</li>
<li><strong> MicroEdition-Profile:</strong> Identifies the J2ME profile that is necessary to run the MIDlet.</li>
<li><strong> MicroEdition-Configuration:</strong> Identifies the J2ME configuration that is necessary to run the MIDlet.</li>
</ul>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;"><strong> Optional Attributes</strong> are </span></p>
<ul>
<li><strong> MIDlet-Icon:</strong> Icon associated with MIDlet, must be in PNG image format.</li>
<li><strong> MIDlet-Description:</strong> Description of MIDlet.</li>
<li><strong> MIDlet-Info-URL:</strong> URL containing more information about the MIDlet.</li>
</ul>
<h3><span style="font-family: Verdana;">3.2) JAD Files</span></h3>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;"><strong> JAD Files</strong> are used to <strong> pass parameters to a MIDlet without modifying the JAR file</strong> . Also used to provide the application manager with additional content information about the JAR file to determine whether the MIDlet suite can be implemented on the device. There are <strong> five necessary attributes</strong> for a JAD file:</span></p>
<h5><span style="font-family: Verdana;">3.2.1)Something About JAD File </span></h5>
<ul>
<li>Files must have the<strong> .jad </strong> extension.</li>
<li>The values of the <strong> MIDlet-Name, MIDlet-Version, and MIDlet-Vendor attributes in the JAD file must match the same attributes in the manifest</strong> .</li>
<li>All entries are name:value pairs.</li>
</ul>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;"><strong> Necessary Attributes</strong> are</span></p>
<ul>
<li><strong> MIDlet-Name:</strong> MIDlet suite name.</li>
<li><strong> MIDlet-Version:</strong> MIDlet version number.</li>
<li><strong> MIDlet-Vendor:</strong> Name of the vendor who supplied the MIDlet.</li>
<li><strong> MIDlet-n: </strong> Location of the JAR file.</li>
<li><strong> MIDlet-Jar-URL: </strong> Attribute per MIDlet. Values are MIDlet name, optional icon, and MIDlet class name.</li>
</ul>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;"><strong> Optional attributes</strong> available are </span></p>
<ul>
<li><strong> MIDlet-Jar-Size:</strong> Size of the JAR file in bytes.</li>
<li><strong> MIDlet-Data-Size:</strong> Minimum size (in bytes) for persistent data storage.</li>
<li><strong> MIDlet-Description:</strong> Description of MIDlet.</li>
<li><strong> MIDlet-Delete-Confirm:</strong> Confirmation required before removing the MIDlet suite.</li>
<li><strong> MIDlet-Install-Notify:</strong> Send installation status to given URL.</li>
</ul>
<h3><span style="font-family: Verdana;">3.3) Programs</span></h3>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">A <strong> MIDlet</strong> is a <strong> class that extends the MIDlet class</strong> and is the <strong> interface between application statements and the run-time environment</strong> , which is controlled by the <strong> application manager</strong> . A MIDlet class must contain <strong> three abstract methods</strong> that are called by the application manager to manage the life cycle of the MIDlet. These abstract methods are.</span></p>
<ul>
<li><strong> startApp():</strong> called by the application manager when the MIDlet is started and contains statements that are executed each time the application begins execution. Public and have no return value nor parameter list.</li>
<li><strong> pauseApp():</strong> called before the application manager temporarily stops the MIDlet. The application manager <strong> restarts the MIDlet by recalling the startApp()</strong> method. Public and have no return value nor parameter list.</li>
<li><strong> destroyApp():</strong> called prior to the termination of the MIDlet by the application manager. Public method without a return value. It has a boolean parameter that is set to true if the termination of the MIDlet is unconditional, and false if the MIDlet can throw a<strong> MIDletStateChangeException.</strong></li>
</ul>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">The Basic Midlet Shell.</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">	public class BasicMIDletShell extends MIDlet
{
	public void startApp(){ }
	public void pauseApp(){ }
	public void destroyApp( boolean unconditional){ }
}</pre></td></tr></table></div>

<p align="justify"><span style="font-size: 10pt; font-family: Verdana;"><strong>MIDP API</strong> classes are used by the MIDlet to interact with the user and handle data management. <strong>User interactions</strong> are managed by <strong>user interface MIDP API classes</strong>. These APIs prompt the user to respond with an <strong>appropriate command</strong>. The <strong>command</strong> causes the MIDlet to execute one of <strong>three routines</strong>: </span></p>
<ul>
<li>Perform a computation.</li>
<li>Make a network request.</li>
<li>Display another screen.</li>
</ul>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">The data-handling MIDP API classes enable the developer to perform four kinds of data routines: </span></p>
<ul>
<li>Write and read persistent data.</li>
<li>Store data in data types.</li>
<li>Receive data from and send data to a network.</li>
<li>Interact with the small computing device’s input/output features.</li>
</ul>
<h3><span style="font-family: Verdana;">3.4) Differences Between Core Java and Java for J2ME </span></h3>
<p align="justify"><span style="font-size: 10pt; font-family: Verdana;">Major Differences are : </span></p>
<ul>
<li><strong>Floating-point math is missing in J2ME</strong>. MIDlet cannot use any floating-point data types or calculations.</li>
<li><strong>Absence of finalize()</strong> method in J2ME.</li>
<li><strong>Reduced number of error-handling exceptions</strong> in J2ME.</li>
<li>JVM for small computing devices requires a <strong>custom class loader</strong> that is supplied by the device manufacturer and cannot be replaced or modified.</li>
<li>We <strong>cannot group threads</strong>. All threads are handled at the object level.</li>
<li>The <strong>class file verification</strong> is replaced with two processes called <strong>Preverificaton</strong> and <strong>Validation</strong>. Preverification occurs prior to loading the MIDLet’s and Validation occurs after loading the MIDLet.</li>
</ul>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2007/07/introduction-to-j2me/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
