How to get the CLDC and MIDP version from a J2ME program

By: Ivan Lim Emailed: 1697 times Printed: 2203 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

The CLDC/MIDP supports system properties, which are key-value pairs that represent information about the platform and environment in which MIDP applications execute. Conceptually these are the same type of properties that you find in J2SE. Unfortunately, there is no java.util.Properties class in CLDC/MIDP to facilitate your handling of properties.

The MIDP specification defines only a small set of standard properties, which are shown in Table
3.4. Implementations may support additional, manufacturer-specific system properties, but these
are nonstandard. You should be aware of what manufacturer- or platform-specific features you use
in order to anticipate portability issues.
Like J2SE applications, MIDP applications can retrieve a system property using the
java.lang.System class. To retrieve the value of a property, use the System class method
String getProperty(String key)
This method retrieves the property value associated with the key whose value is specified in the
call.

Standard CLDC System Properties

Property  Key Description Default Value
microedition.configuration Name and version of the supported configuration CLDC-1.0
microedition.encoding Default character encoding set used by the platform ISO8859-1
microedition.locale Name of the platform's current locale null
microedition.platform Name of the host platform or device null
microedition.profiles Names of all supported profiles null


  A sample J2ME program illustrates the retrieval of system properties in a MIDlet.

MIDlets have direct access to all four of the standard system properties defined by the CLDC specification.
 

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
/**
Creates the "Hello world" program in J2ME MIDP.
Note that the class must be public so that the device
application management software can instantiate it.
*/
public class HelloWorld extends MIDlet
{
...
public void startApp()
{
// Create a Displayable widget.
form = new Form("Hello World");
// Add a string to the form.
String msg = "My first MIDlet!";
form.append(msg);
// This app simply displays the single form created
// above.
display = Display.getDisplay(this);
display.setCurrent(form);
printSystemProperties();
}
/**
Prints the values of the standard system properties
using the System.getProperty() call.
*/
protected void printSystemProperties()
{
String conf;
String profiles;
String platform;
String encoding;
String locale;
conf = System.getProperty("microedition.configuration");
System.out.println(conf);
profiles = System.getProperty("microedition.profiles");
System.out.println(profiles);
platform = System.getProperty("microedition.platform");
System.out.println(platform);
encoding = System.getProperty("microedition.encoding");
System.out.println(encoding);
locale = System.getProperty("microedition.locale");
System.out.println(locale);
System.out.println();
}
 

}

Notice the addition of the call to the method printSystemProperties() at the end of the startApp() method. This method simply retrieves and prints to standard output the values of the five standard MIDP system properties. The data that the program writes to standard output is shown next:\

CLDC-1.0
MIDP-1.0
j2me
ISO-8859-1
en_US


J2ME Home | All J2ME Tutorials | Latest J2ME Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(2)


1. View Comment

I am looking for a J2ME programmer that can create a simple application that sends a cellular phones Latitude / Longitude to a specific IP Address.

Compensation will be discussed.

Thaks,

Gary Wallis
gwallis@wi.rr.com
414/698-8537

View Tutorial          By: Gary Wallis at 2007-10-14 15:35:00
2. View Comment

Please tell me the process, how to compile the midlet. I have a wtk2.5.0 and jdk1.5.0 send me one example which can describe whole process of compilation of j2me midlet. I dont know from where(which folder in my computer) i save my source code and the main thing how i set the path in my computer. Please rectify the problem as soon as possible.

View Tutorial          By: Manish at 2008-11-14 13:33:43

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Ivan Lim
Requesting a Signed Certificate from a Certification Authority example using keytool in Java
The if-then Statement in Java
SELECT Statements
The BodyTag Interface in JSP
Handling Duplicate Form Submissions in Struts
Standard Input and Output in C
A sample that shows Java Beans, Servlets and JSP working together
Recursion in C
Using Multibox in Struts
switch in C
Word Counting sample program in C
Java Bean Scopes in JSF
Using cout.width() in C++
Types of configurations in J2ME
How to get the CLDC and MIDP version from a J2ME program

More Tutorials in J2ME
Code sample to Send SMS from a J2ME application.
Adding your own Application icon for your J2ME application (jar file)
Play a multimedia file in J2ME Program (Audio/Video) using MMAPI
Datagrams in J2ME (UDP Programming sample)
Client Server in J2ME (Socket Programming sample)
Using HttpConnection in J2ME (Retrieve web content from a website to a phone)
Using HTTP vs UDP vs Socket in J2ME
RMSCookieConnector - Using Cookies in J2ME
POST UTF-8 encoded data to the server in J2ME
lists, forms, choices, gauges, text fields, text boxes in J2ME
Using List to create a Menu and Menu items in J2ME
Using alerts and tickers in J2ME
J2ME Canvas sample to show games programming in J2ME
Timer and TimerTask example in J2ME
List of GPRS Access points for all countries

More Latest News
Most Viewed Articles (in J2ME )
Sample Java program shows how to Read a file over a network using J2ME midlet
GUI components and menu based J2ME Applications.
How to get the CLDC and MIDP version from a J2ME program
Types of configurations in J2ME
Code sample to Send SMS from a J2ME application.
Y.S. Sun Green Building Research Center
Sample J2ME code that shows various functionality of RMS.
A sample J2ME midlet that shows an example of using a Timer and a TimerTask.
Gauge sample program in J2ME
Ticker sample program in J2ME
Sample program to draw a arc in J2ME
getPosition() the right strategy in getting GPS
Timer and TimerTask example in J2ME
Datagrams in J2ME (UDP Programming sample)
Client Server in J2ME (Socket Programming sample)
Most Emailed Articles (in J2ME)
What is J2ME?
Download a file over a network in J2ME midlet
Image and ImageItem sample program in J2ME
TextBox sample program in J2ME
Sample program to draw a arc in J2ME
Client Server in J2ME (Socket Programming sample)
Y.S. Sun Green Building Research Center
'LINK.EXE' is not recognized as an internal or ext
Sample program to draw a rectangle in J2ME
RMS Basics in J2ME
Types of configurations in J2ME
Types of Profiles in J2ME
A sample J2ME Auto-resume program.
Timer and TimerTask example in J2ME
lists, forms, choices, gauges, text fields, text boxes in J2ME