This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

System Information Code not running  RSS feed

waqas shahwar
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.*;
public class SysInfo extends MIDlet implements CommandListener {
private Command exitCommand;
private Display display;
private Form screen;
public SysInfo() {
// Get the Display object for the MIDlet
display = Display.getDisplay(this);
// Create the Exit command
exitCommand = new Command("Exit", Command.EXIT, 2);
// Create the main screen form
screen = new Form("SysInfo");
// Obtain the current time
Calendar calendar = Calendar.getInstance();
String time = Integer.toString(calendar.get(Calendar.HOUR)) + ":" +
Integer.toString(calendar.get(Calendar.MINUTE)) + ":" +
// Obtain the total and free memory, and convert them to strings
Runtime runtime = Runtime.getRuntime();
String totalMem = Long.toString(runtime.totalMemory());
String freeMem = Long.toString(runtime.freeMemory());
// Obtain the display properties
String isColor = display.isColor() ? "Yes" : "No";
String numColors = Integer.toString(display.numColors());
// Create string items and add them to the screen
screen.append(new StringItem("", "Time: " + time));
screen.append(new StringItem("", "Total mem: " + totalMem));
screen.append(new StringItem("", "Free mem: " + freeMem));
screen.append(new StringItem("", "Color: " + isColor));
screen.append(new StringItem("", "# of colors: " + numColors));
// Set the Exit command
public void startApp() throws MIDletStateChangeException {
// Set the current display to the screen
public void pauseApp() {
public void destroyApp(boolean unconditional) {
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
Lasse Koskela
Posts: 11962
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "not running"?
PS. Using the UBB [CODE]tags[/CODE] makes it easier for others to read your code snippets
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!