Beginner in J2me
Hi all,
I'm new to this J2ME programming. Can anyone explain to me how to use the new Command() function.
Can anyone please explain to me what each parameter means for, especially the "2".
new Command("Select", Command.OK, 2).
In addition, I'd appreciate if someone can direct me to a J2ME manual that consists of the method explainations (like MSDN).
I'm using Eclipse to program if this means anything.
Thanks.
Command(String label, int commandType, int priority)the 2 stands for the priority. 0 means high priority (important), the lower the priority is, the longer is the navigation way, when multiple commands can be selected on one soft button. Its just a hint for the implementation of the phones, where to place the command.
look at http://java.sun.com/j2me/ there you can find anything regarding the J2ME development. The Wireless Toolkit includes a complete javadoc of MIDP and CLDC and should be this, what you are looking for. I dont know, whether the javadoc can be downloaded seperately. Maybe you should try the links to MIDP or CLDC.
hth
Kay
Similar Messages
-
hi,
i am beginner to j2me programming.My problem is i have written a small programme using J2me API and able to successfully compileit, but i am unable to preverify it, it is giving me classNotfound exception,
Thanking you in advance,
Regds,
Kavitha JayannaDid you add the "-bootclasspath" options when you complie. you should add your j2me path behind it,
such as"-bootclasspath c:\midp1.03fca\classes"
Or when you preverify ,did you add the "-classpath"
option.such as "-classpath c:\midp1.03fca\classes;." -
Beginner in J2me-Need some tips
I am in a project that requires developing a java application on symbian OS based mobiles.
Can someone tell me which software wud be the best to develop upon?Also it should be for free download
1. Metrowerks CodeWarrior Wireless Studio 7
2. jVise from S5 Systems
3.JBuilder 7 Enterprise with MobileSet 3
4.Sun J2ME Wireless ToolKit
I am a novice in developing and i just have knowledge of core javaSo what you are saying is that its impossible in
java,J2EE,J2Me????J2ee stuff does not run on j2me devices. You are bound to the j2me api stuff.
Okay c++ is excellent, i am fine with it, then how do
i go about doing this java project.My project leader
is a project manager of that company, and hes into
programming for years, so i don't think he wud give
an impossible task. Well, saidly, in on this topic he is wrong. Look at the j2me api docs and see for yourself: there is no way you can do this with java on a mobile device.
So could you find out some info for me.I came to this
forum for some help as i am tired of serching sites
.I did not get fruitful results as i have been trying
for days together.I can imagine that, since what you want to do is fairly uncommon and unusiual.
I can't give you more info than to look into the C++/symbian world :( Bad thing is that you lose your large device base. -
J2ME beginner needs help ???
Hello,
I am a beginner on J2ME.
In the WTK21, I just see those compiled file in .jad format. How can I deploy it to the PalmOS or PocketPC ?
Do I need to install any Java VM in that ?? Where I can find this ???
Best regards,
EricSad to say that the palm pilot and pocket pc has its own profile as well just like the Sun's J2ME Wireless Toolkit which is using the MIDP profile. Therefore, to simply transfer the jar and jad file into your palm or pocket pc won't work at all.
Yes, you can download KVM for your Palm and Pocket PC however, the KVM is just another VM that interprets java. For the Palm, I used KJava the last time round. If you have the source codes, you will noticed that the KJava builds on CLDC then the KJava Profile for the palm pilot.
Thus the GUI part, you have to use the Palm/Pocket PC GUI API. While the application logic stays. That means, you have to get the targeted emulator to run and test your program once again.
In additon, you would want your application to be in full-screen mode on the targeted device rather than a small window,especailly for games, you will want the graphics to be displayed at its optimum resolution. , That is why programmers out there like to separate presentation from the data so that if the presentation changes, you will only have to touch the presentation codes.
The other better solution is to have another VM that runs Palm, MIDP and Win CE Profile without any big hassle.. Take a look http://www.esmertec.com/solutions/ -
No Image in my cell but there's an image in J2ME wireless toolkit
Hi all,
I'm really lost here. I coded my java code and run it in J2ME wireless toolkit and the image is there, I put the image on the res folder and the image file format is .PNG, its working in the default color phone. However whe send it to my cellphone, sending the .jar file, and after installation, as I run the program, I cant see the image, all UI is ok but not the image. Thanks a lot
Here's the code:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HelloWorld extends MIDlet implements CommandListener, ItemStateListener
private Form frm;
private Display display;
private TextField txtName;
private TextField txtAge;
String[] genderArray = {"Male", "Female"};
private ChoiceGroup gender;
String[] statusArray = {"Single", "Married", "Widow"};
private ChoiceGroup status;
private Command cmdExit;
public HelloWorld( )
display = Display.getDisplay(this);
frm = new Form("Hello World");
txtName = new TextField("Name: ","",40,TextField.ANY);
txtAge = new TextField("Age: ","",2,TextField.NUMERIC);
Image[] imageArray2 = null;
Image[] imageArray3 = null;
try {
Image icon = Image.createImage("/icon.png");
Image img = Image.createImage("/myPic.png");
imageArray2 = new Image[] {icon, icon};
imageArray3 = new Image[] {icon, icon, icon};
frm.append(new ImageItem(null, img, ImageItem.LAYOUT_CENTER,null));
} catch(java.io.IOException err)
// Found an error
gender = new ChoiceGroup("Gender: ",ChoiceGroup.EXCLUSIVE,genderArray,imageArray2);
status = new ChoiceGroup("Status: ",ChoiceGroup.POPUP,statusArray,imageArray3);
cmdExit = new Command("Exit",Command.EXIT,1);
frm.addCommand(cmdExit);
frm.append(txtName);
frm.append(txtAge);
frm.append(gender);
frm.append(status);
public void startApp( )
display.setCurrent(frm);
public void pauseApp( )
public void destroyApp(boolean unconditional)
public void commandAction(Command c, Displayable s)
if ( c == cmdExit )
destroyApp(false);
notifyDestroyed( );
public void itemStateChanged(Item item)
Thanks.HI Phoenix_Mj
I'm a beginner in J2ME world and it might happen that I'm be missing some impt step from coding to transferring.
Do I have to configure anything?
Im I right by saying, only the .jar file is then transmitted to the device?
Lastly, where should I put my images? what folder to be specific?
I can't run the application correctly even trying to run it over the OTA....
No images is being displayed...
Please help guys.
By the way thanks, Phoenix_Mj
God Bless to all -
Develop J2ME application for Pocket PC
Hi everyone,
I'm a beginner in J2ME, I would like to ask what should I use to develop app for PPC.
As I know, PersonalJava is good for it, but it already end of life, then is it good now? And I've heard Kjava & Kawt are also for PPC since I'm looking for a package which included java.awt & event. How about them?
Thank you very much!
GaryPerhaps this will be useful, http://www.vikdavid.com/mobile/
Viru Doshi -
Getting cell-id and location using j2me/symbian
Hello frens
i m beginner to j2me and task is
get cell id location of mobile terminal by sending a sms to that mobile terminal ,
How to achieve thisJSR-179 points you to how to do this in J2ME . The problem is that no one has implemented the Location API on their fones as yet. Ok apart from Nokia and then only for some of their high end fones. Any one been able to create a JNI wrapper and get the details from handset? If you have you can save me hours of pain! :-)
-
Can anybody help me with this code?
I am a beginner to J2ME. The following is a small program I wrote just for test.
Theoretically, in my opinion, I shall see in the screen a number increase from 1 to 29999 rapidly after execute the code. But instead, it displays nothing but only displays 29999 after several seconds . Can some body point out what's wrong with this code? Thanks.
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Test extends MIDlet{
int x=1;
String b="";
private Display display;
public Test() {
display = Display.getDisplay(this);
public void startApp() {
MyCanvas mc = new MyCanvas() ;
display.setCurrent(mc) ;
while(x<30000){
b=String.valueOf(x);
mc.repaint();
x++;
public void pauseApp() {
public void destroyApp(boolean unconditional) {
class MyCanvas extends Canvas{
public void paint(Graphics g){
g.drawString(b,10,10,0);thanks, I have already got the answer. you are right, if repaint in a high speed the screen will show nothing. here is the code for it, thanks the expert of nokia forum.
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
//Counter
//Need to know when a number has been painted and need to wait a for a fraction of a sec before
//painting the next number. This wait also allows other events like "Exit" to be processed
//Use double buffering to avoid flicker
//Paint in a different thread to keep the UI responsive
public class MyMIDlet extends MIDlet{
int x=1;
String b="";
private Display display;
Thread t = null;
MyCanvas mc = null;
public MyMIDlet() {
display = Display.getDisplay(this);
public void startApp() {
mc = new MyCanvas();
t = new Thread(mc) ;
display.setCurrent(mc) ;
b=String.valueOf(x);
t.start();
public void callbackPaintDone(){
try{
//provides the delay between every repaint and also time to react to Exit
synchronized(this){
wait(1);
}catch(Exception e){}
paintNextNumber();
private void paintNextNumber(){
if(x<30000){
x++;
b=String.valueOf(x);
mc.doPaint = true; //signals that next number can be painted
public void pauseApp() {
public void destroyApp(boolean unconditional) {
class MyCanvas extends Canvas implements Runnable{
Image buf = null;
Graphics bg = null;
public boolean doPaint = true;
public MyCanvas(){
buf = Image.createImage(getWidth(),getHeight());
bg = buf.getGraphics();
public void paint(Graphics g){
bg.setColor(255,255,255);
bg.fillRect(0,0,getWidth(),getHeight());
bg.setColor(0);
bg.drawString(b,10,10,0);
g.drawImage(buf,10,10,Graphics.TOP|Graphics.LEFT);
// Callback for next number to be painted
MyMIDlet.this.callbackPaintDone();
public void run(){
while(true){
if(doPaint){ //only paints when a number has been painted, and next one is ready to be painted
doPaint = false;
repaint();
serviceRepaints(); -
Problem with openInputStream (nokia 6233)
Hi,
I am a beginner in J2ME.
I try to make a connection on my nokia 6233 but the connection failed on openInputStream() with Exception.
I use the following code:
=================================================
String url = "http://www.javacourses.com/hello.txt";
InputStream is = null;
HttpConnection hc = null;
try {
hc = (HttpConnection)Connector.open(url);
is = hc.openInputStream();
catch (IOException e) {
=================================================
the connection with hc = (HttpConnection)Connector.open(url) is OK
the hc.openInputStream() is KO
Thanks in advance.micotn
Welcome to the forum. Please don't post in old threads that are long dead. When you have a question, please start a topic of your own. Feel free to provide a link to an old thread if relevant.
I'm locking this thread now.
db -
Hi.. I'm a beginner on J2ME. Now i'm trying to make an application using JSR-75 and when i try to make a file, there's an error message:
java.io.IOException: Root is not accessible
at com.sun.midp.io.j2me.file.Protocol.ensureConnected(+47)
at com.sun.midp.io.j2me.file.Protocol.ensureOpenAndConnected(+21)
at com.sun.midp.io.j2me.file.Protocol.create(+8)
at JCompression.encode(+110)
at JCompression$2.run(+26)
What's wrong with that? Please help me..
Here's my source code:
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.Ticker;
import java.io.IOException;
import java.io.InputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.util.Enumeration;
import javax.microedition.io.file.*;
import javax.microedition.io.Connector;
public class JCompression extends MIDlet implements CommandListener
private String currDirName;
private final static String MEGA_ROOT="/";
private final static String UP_DIRECTORY = "..";
private final static char SEP = '/';
private final static String SEP_STR = "/";
private final static String EXTENSI = ".jcf";
private Image directoryIcon, fileIcon, compressedIcon;
private Image[] iconList;
private Command view = new Command("View", Command.ITEM, 1);
private Command prop = new Command("Properties", Command.ITEM, 2);
private Command compress = new Command("Compress", Command.ITEM, 3);
private Command uncompress = new Command("Uncompress", Command.ITEM, 4);
private Command back = new Command("Back", Command.BACK, 2);
private Command exit = new Command("Exit", Command.EXIT, 3);
public JCompression()
currDirName = MEGA_ROOT;
try
directoryIcon = Image.createImage("/icons/dir.png");
catch (IOException ioe)
directoryIcon = null;
try
fileIcon = Image.createImage("/icons/file.png");
catch (IOException ioe)
fileIcon = null;
try
compressedIcon = Image.createImage("/icons/compress.png");
catch (IOException ioe)
compressedIcon = null;
iconList = new Image[] {directoryIcon, fileIcon, compressedIcon};
public void startApp()
try
showCurrDir();
catch(SecurityException e)
Alert myAlert = new Alert("Error", "Anda tidak diberi hak untuk mengakses", null, AlertType.ERROR);
myAlert.setTimeout(Alert.FOREVER);
Form myForm = new Form("Tidak dapat mengakses FileConnection");
myForm.append("Anda tidak dapat menjalankan MIDlet ini dengan izin yang ada saat ini.\n"
+ "Beri izin pada MIDlet suite, atau jalankan dengan security domain yang berbeda");
myForm.addCommand(exit);
myForm.setCommandListener(this);
Display.getDisplay(this).setCurrent(myAlert, myForm);
catch(Exception e)
e.printStackTrace();
public void pauseApp()
public void destroyApp(boolean b)
notifyDestroyed();
public void commandAction(Command c, Displayable d)
if (c == view)
List curr = (List) d;
final String currFile = curr.getString(curr.getSelectedIndex());
new Thread(new Runnable() {
public void run() {
if (currFile.endsWith(SEP_STR) || currFile.equals(UP_DIRECTORY)) {
traverseDirectory(currFile);
} else {
showFile(currFile); // show file contents
}).start();
else if (c == prop)
List curr = (List) d;
final String currFile = curr.getString(curr.getSelectedIndex());
//showProperties(currFile);
else if (c == compress)
List curr = (List) d;
final String currFile = curr.getString(curr.getSelectedIndex());
new Thread(new Runnable() {
public void run() {
if (currFile.endsWith(SEP_STR)) {
// Do nothing
} else {
encode(currFile);
}).start();
else if (c == uncompress)
List curr = (List) d;
final String currFile = curr.getString(curr.getSelectedIndex());
new Thread(new Runnable() {
public void run() {
if (currFile.endsWith(EXTENSI)) {
decode(currFile);
} else {
// Do nothing
}).start();
else if (c == back)
showCurrDir();
else if (c == exit)
destroyApp(false);
void showCurrDir()
Enumeration e;
FileConnection currDir = null;
List browser;
Ticker myTicker = new Ticker("");
try
if (MEGA_ROOT.equals(currDirName))
e = FileSystemRegistry.listRoots();
browser = new List(currDirName, List.IMPLICIT);
myTicker.setString("Address: [ Roots ]");
else
currDir = (FileConnection) Connector.open("file://localhost/" + currDirName);
e = currDir.list();
browser = new List(currDirName, List.IMPLICIT);
browser.append(UP_DIRECTORY, directoryIcon);
myTicker.setString("Address: [ file:///" + currDirName + " ]");
while(e.hasMoreElements())
String fileName = (String) e.nextElement();
if (fileName.charAt(fileName.length()-1) == SEP)
// This is directory
browser.append(fileName, directoryIcon);
else if (fileName.endsWith(EXTENSI))
// This is compressed file
browser.append(fileName, compressedIcon);
else
// This is regular file
browser.append(fileName, fileIcon);
browser.setTicker(myTicker);
browser.addCommand(view);
browser.addCommand(prop);
browser.addCommand(compress);
browser.addCommand(uncompress);
browser.addCommand(exit);
browser.setSelectCommand(view);
browser.setCommandListener(this);
Display.getDisplay(this).setCurrent(browser);
if (currDir != null)
currDir.close();
catch (IOException ioe)
ioe.printStackTrace();
void traverseDirectory(String fileName)
if (currDirName.equals(MEGA_ROOT))
if(fileName.equals(UP_DIRECTORY))
// can not go up from MEGA_ROOT
return;
currDirName = fileName;
else if (fileName.equals(UP_DIRECTORY))
// go up one directory
int i = currDirName.lastIndexOf(SEP, currDirName.length()-2);
if (i != -1)
currDirName = currDirName.substring(0, i+1);
else
currDirName = MEGA_ROOT;
else
currDirName = currDirName + fileName;
showCurrDir();
void showFile(String fileName) {
try {
FileConnection fc = (FileConnection)
Connector.open("file://localhost/" + currDirName + fileName);
if (!fc.exists()) {
throw new IOException("File does not exists");
InputStream fis = fc.openInputStream();
byte[] b = new byte[1024];
int length = fis.read(b, 0, 1024);
fis.close();
fc.close();
TextBox viewer = new TextBox("View File: " + fileName, null, 1024,
TextField.ANY | TextField.UNEDITABLE);
viewer.addCommand(back);
viewer.addCommand(exit);
viewer.setCommandListener(this);
if (length > 0) {
viewer.setString(new String(b, 0, length));
Display.getDisplay(this).setCurrent(viewer);
} catch (Exception e) {
Alert alert = new Alert("Error!", "Can not access file " + fileName
+ " in directory " + currDirName + "\nException: "
+ e.getMessage(), null, AlertType.ERROR);
alert.setTimeout(Alert.FOREVER);
Display.getDisplay(this).setCurrent(alert);
void encode(String fileName)
final int high, low, codeRange, highRange, lowRange;
try
String fOutName = "fileOutput";
FileConnection fc = (FileConnection) Connector.open("file://localhost/"
+ currDirName + fileName);
FileConnection fOut = (FileConnection) Connector.open("file:///localhost/"
+ currDirName + fOutName);
if (!fc.exists())
throw new IOException("File does not exists");
if (!fOut.exists())
fOut.create();
DataInputStream dis = fc.openDataInputStream();
DataOutputStream dos = fc.openDataOutputStream();
int ukuran = dis.available();
byte[] b = new byte[ukuran];
// int tmp = fis.read(b, 0, ukuran);
dis.close(); dos.close();
fc.close(); fOut.close();
catch(Exception e)
e.printStackTrace();
void decode(String fileName)
}Please help me, because i must finish this project as fast as i can. Thank you..Sorry for the late reply.
I've found my mistake a few days ago. I write more slash in it. It's:
FileConnection fOut = (FileConnection) Connector.open("file:///localhost/"+ currDirName + fOutName);
But i want to ask you, you wrote:
"Go to Edit->Preferences->Storage tab and Empty all 3 fields(specially 1st field)"
What it used for? When i checked it, it's all empty.
Thank you for your time and help. :) -
hi, i'm beginner in j2me...
I was wondering how to call to other form(class) in the current form...
For example,
public class A extends MIDlet implements CommandListener
public void commandAction(Command d,Displayable s)
if (d==*OKCommand*)
if press this OK command, it will be able to show another form declared in the different class...
How to make it able to call to other form/class(eg.classB)????
public class B
//form that will be shown after pressed command OK in class A
please help if you know...Thanks a lot..... =)you MUST have a reference to the other class or MIDlet in the current MIDlet ...
i think that i have answered to these kind of questions a few month ago.. you should use the 'search' engine to find the topic..
CLDC and MIDP forum is not a huge forum compare to Java Programming forum so it will be easy ! -
hello, I'm a beginner in j2me and I'm developing an application that receive a message via socket, and I want my application to be always ready to receive the message even if it not running. I thought of static push registry put the thing I couldn't understand are:
- my application must send different messages for each clients, so is pushing to the registry will help me here ??
- when I use it how the connection be established (I mean do I have to write connecter.open()), because I use the dynamic one and by the example provided by sun I create the connection and then push it to registry ..???
- do I need some specific code to be written on the server side ?
- can u please give the steps of how to test static push registry ??
hope u will help me ^_^
thanksI understood what I want but I stuck in a problem with static push-registry, it work fine on the emulator but when I install it on a real device nothing happen.
the device I use is E71 .. I want to know if anyone try push with it and he success or E71 is not supporting static push-registry.
when I install the application it dose ask me if I agree to run it automatically ..... also, I try the dynamic one and it success...
thanks -
Is it possible to know which bluetooth services are available with a MIDlet
...Bluetooth Services like Serial Port Support, Obex File Transfer, Dial-up Networking...
I've already try to search with "getProperty()" (api.version, n� max. of devices...) but it awlays return "null" !!!!. I'm a beginner in j2me BLUETOOTH. Thanks!Varies from phone to phone.
I believe it is recommended to use a port between
16001 and 16999 on a J2me app as these are almost
always free.
In my opinion the best way to find out what will work
and what won't is to create a small app which will
try to create an SMS connection on a specified port
(specified through something like a textbox) and
which will display something indicative if an
IOException is thrown during the process of
creation.
Most manufacturers usually also have documentation on
this on their developer sites...hi i have a similar problem with they guy above
i have installed a camera network wich has acces to web from port 8080 i have access from any computer that has internet but when i connect with the java app provided from the cameras company it throws "java.lang.securityexception untrusted midlet attempted to connect to a restricted port" i was wondering if i change te port tha i connect will i have access from that program?? and if yes wich port should i use? i am asking because its not easy to have access to the router to change the port forwarding settings thank you in advance -
hi, i am doing a project, and i want to add a sms system, which eable the administrator to send a text message to the registed user's mobile, but as i am a beginner at J2ME, i don't even konw where to start, if any one can help me on this i would be very greatful!!!
thank you for ur time.
appleLike we have MyContacts Backup for Contacts in iPhone.....
Do we have any application for iPhone to backup the SMS.?? -
Can I get the number input from TextField ?
I have a beginner in J2ME.
Can I write ...
tfTime=new TextField("After this","",4,TextField.NUMERIC);
time=tfTime.getString();
t=Integer.parselInt(time);
For my purpose? Or Do you have any suggestion?
And If I want to show TextBox in the next display.
It will alarm after this
20 second
How can I get number t from TextField to appear in TextBoxIf you want to get the content of a TextField and put it on a TextBox, you dont need to parse it to int.
Just do this:
time = tfTime.getString();
TextBox tBox = new TextBox("", time, ...);
Ricardo
Maybe you are looking for
-
I have multiple calendars on my Google account, though I mostly use my work calendar and my personal calendar. The personal calendar is the main one attached to my Gmail account. My problem is that when I create an event on my work calendar, it regis
-
[SOLVED]Compilation Issues:
How does one simply compile a program that can "just run?" I used GCC as a Windows user and never once did I have issues with it. The wiki, assuming there's a proper page for it, should have something for compilation in it. If there's any other resou
-
Having problems downloading software
Hello all, I'm having issues downloading things from the internet. I'm up to date on the software for my MacBook Pro. When I try to download something it goes to a white web page and the status bar only fills up half way. Have I picked up some malwar
-
SAPCCM4X agent reports active eventhough its stopped at OS level
We are having sapccm4x agent running on NW PI 7.1 system connected to Solman 7.0 When we stop the agent or if the agent process stops / killed, normally its reported at SAP level as Inactive and availability as 0 On Solman system RZ21 --> Technical I
-
Include using jsp:include for a file from the docroot directory.
Hello, I try to include one file from the doocroot but only can import files from the context (War deployed). when I put <jsp:include page="/foo.htm"> to include this file: http://www.mydomain.com/foo.html it try to show this file: http://www.mydomai