README.md

December 4, 2022 ยท View on GitHub

Creating a Cellphone Game/Application

Description

Learn how to create a game or application for your cellphone.

More Info

Submitted On
ByR. Kistner
LevelBeginner
User Rating4.4 (57 globes from 13 users)
CompatibilityJava (JDK 1.2)
CategoryMiscellaneous
WorldJava
Archive File

Source Code

Creating Cellphone Game or Application

by Ralf Kistner

To create a game or application for your cellphone, you need the following:

  • Jdk1.3 or higher (http://java.sun.com/j2se/1.4.1/download.html)
  • J2ME Wireless Toolkit (http://java.sun.com/products/j2mewtoolkit/download-2_0.html)
  • Any Java IDE or text editor
  • A java-compatible cellphone (optional)

Note: This is not a tutorial to teach you Java. You should be confident with Java before reading this tutorial.

Getting started with J2ME

Step 1: In J2ME Wireless Toolkit, create a new project. Give the project any name you want. Make the class name Main. You don't need to change any of the settings.

Step 2: Create [J2ME home dir]\apps\[project name]\src\Main.java with the following code:


import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
public class Main extends MIDlet {
	private Form mainForm;
	public Main() {
		//create a new Form with the specified title
		mainForm = new Form("Hello World");
		//append a String to the form
		mainForm.append("Hello World!");
	}
	public void startApp () {
		//show the Form in the display area
		Display.getDisplay(this).setCurrent(mainForm);
	}
	public void destroyApp(boolean b) { }
	public void pauseApp() { }
}

Step 3: In J2ME, build the project. If you don't get any errors, you can run your program. A frame with a picture of a cellphone should pop up. Click on the button under launch and you should see "Hello World!".

Congratulations! You've just created your own cellphone application!

Step 4: To get it on your cellphone, you'll have to create a package (Project-> Package-> Create Package). See your cellphone's manual for futher instructions on how to put it on your cellphone.