J2me error
when i add (implements CommandListener) in my class the netbeans appear to me(class is not abstract and dose not override abstract method)
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Midletstates extends MIDlet implements CommandListener
private Display display;
private Command exitcommand;
private TextBox textbox;
public Midletstates()
System.out.println("The MIDletStates Constractor is Invoked");
exitcommand=new Command("Exit", Command.EXIT,1);
textbox=new TextBox("MIDlet's States Demo", "Hello:)",15, 0);
textbox.addCommand(exitcommand);
textbox.setCommandListener(this);
public void startApp()
System.out.println("The startApp method is invoked");
display=Display.getDisplay(this);
display.setCurrent(textbox);
public void pauseApp()
System.out.println("The PauseApp Method is Invoked");
public void destroyApp(boolean cond)
System.out.println("The DestoryApp Method Is Invoked");
public void commandaction(Command command,Displayable displayable)
if(exitcommand==command)
destroyApp(true);
}
Stop trolling.
{color:0000ff}http://forum.java.sun.com/thread.jspa?threadID=5270506{color}
db
Similar Messages
-
J2ME error to get value from variable in another class
hi,,
i write code for a mobile application like a tour guide..
i had create 5 class for this application, KutaBeachDictionary MIDlet class, ListMainMenu List class, ListMenuHotel List class, HotelDes01 Form class and the last Hotel class that store all information.
the problem is, i have [choose] variable in ListMenuHotel that contain getSelectedIndex() value, i want to take [choose] value from ListMenuHotel class to [index] variable in HotelDes01, so it determine the name of hotel that will display in form.but the index always 0 although i had choosen different menu from ListMenuHotel..
here is all code
in MIDlet class
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;
public class KutaBeachDictionary extends MIDlet {
public KutaBeachDictionary() {
lstMenuUtama = new ListMenuUtama(this);
lstMenuHotel = new ListMenuHotel(this);
htlDes1 = new HotelDes01(this);
frmLoading = new FormLoading(this);
public Display getDisplay() {
return Display.getDisplay(this);
public void exitMIDlet() {
switchDisplayable(null, null);
destroyApp(true);
notifyDestroyed();
public void startApp() {
if (midletPaused) {
resumeMIDlet();
} else {
initialize();
startMIDlet();
midletPaused = false;
getDisplay().setCurrent(frmLoading);
new Thread(frmLoading).start();
frmLoading.done = false;
frmLoading.gLoading.setValue(0);
public void pauseApp() {
midletPaused = true;
public void destroyApp(boolean unconditional) {
private boolean midletPaused = false;
public ListMenuHotel lstMenuHotel;
public ListMenuRestaurant lstMenuRestaurant;
ListMenuUtama lstMenuUtama;
FormAbout frmAbout;
public HotelDes01 htlDes1;
FormLoading frmLoading;
}the code in ListMenuHotel
import java.io.IOException;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.Ticker;
public class ListMenuHotel extends List implements CommandListener {
Hotel objHotel = new Hotel();
ListMenuHotel(KutaBeachDictionary run) {
super("List Hotel", List.IMPLICIT);
this.run = run;
try {
btnImage = Image.createImage("/btnImage.png");
} catch (IOException e) {
tickerMenu = new Ticker("Daftar Hotel di Pantai Kuta Bali");
setTicker(tickerMenu);
for (int i = 0; i < objHotel.namaHotels.length; i++) {
append(objHotel.namaHotels, btnImage);
addCommand(new Command("Select", Command.OK, 0));
addCommand(new Command("Back", Command.BACK, 0));
setCommandListener(this);
public void commandAction(Command cmd, Displayable dsp) {
if (cmd == SELECT_COMMAND) {
choose = getSelectedIndex();
Display.getDisplay(run).setCurrent(run.htlDes1);
switch (cmd.getCommandType()) {
case Command.BACK:
Display.getDisplay(run).setCurrent(run.lstMenuUtama);
break;
public int getChoose() {return choose;}
private KutaBeachDictionary run;
private Image btnImage;
private Ticker tickerMenu;
private int choose;
the code in HotelDes01 Form classimport java.io.IOException;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
public class HotelDes01 extends Form implements CommandListener {
private KutaBeachDictionary run;
private int index;
private Hotel isiHotel = new Hotel();
public HotelDes01(KutaBeachDictionary run) {
super("Inna Kuta Hotel");
index = run.lstMenuHotel.getChoose(); //here is the problem..the value remain 0 althought i choose another??!!
this.run = run;
Image imgHotel = null;
String namaHotel = "\n" + isiHotel.namaHotels[index] + "\n";
try {
imgHotel = Image.createImage("/HotelImage/interface/htlDes1.png");
} catch (IOException e) {
append(new ImageItem(null, imgHotel, ImageItem.LAYOUT_CENTER, null));
append(namaHotel);
addCommand(new Command("Back", Command.BACK, 0));
setCommandListener(this);
public void commandAction(Command cmd, Displayable dsp) {
switch (cmd.getCommandType()) {
case Command.BACK:
Display.getDisplay(run).setCurrent(run.lstMenuHotel);
break;
can someone fix the code,, i had tried so many ways,,but completely failure.. T_T
Edited by: diaca on Mar 22, 2010 7:55 AM
Edited by: diaca on Mar 22, 2010 8:01 AMhei bro,i had solved the problem :)
the problem is , i had constructed the form of hotelDes01 each time the program starting with this code
public class KutaBeachDictionary extends MIDlet {
public KutaBeachDictionary() {
//.. declaring several new object
htlDes1 = new HotelDes01(this);
//..another procedure like startApp, pauseApp, etc
public HotelDes01 htlDes1;
}i think if i declare this class in the beginning it never updated the index value
so i delete the code above, and i declare the htlDes1 in the listMenuHotel like this:
public class ListMenuHotel extends List implements CommandListener {
//..several code just like before
public void commandAction(Command cmd, Displayable dsp) {
if (cmd == cmdSelect) {
objHotel.setChoose(getSelectedIndex()); //i change the code like this
showInformation();
if (cmd == cmdBack) {
Display.getDisplay(run).setCurrent(run.lstMenuUtama);
public void showInformation() {
HotelDescription htlDes1 = new HotelDescription(run); //reconstruct the object in the class ListMenuHotel
Display.getDisplay(run).setCurrent(htlDes1); //display the object
}so the form of hotelDes01 now always reconstruct whenever user change the election in ListMenuHotel class and now index value get updated.. :D
thanks for trying to fix the code qnat..
this is my coursework, so i get to finish it ASAP.. -
Error while running J2ME program in KtoolKit
hi,
i am doing my project in j2me as i m developing a Jabber client .where my Client application has to connect jabber server through GPRS...
so while running the project in KToolKt it ask that client application wants to send the information this requires airtime which may cost you money.is this ok?(TCP)
after clicking on yes option program goes in deadlock...thorws following error message
Error
=====
Warning: To avoid potential deadlock, operations that may block, such as
networking, should be performed in a different thread than the
commandAction() handler.
===================
plz send me solution if you know....
regards...jhd
hi.
this is a common error whenever we are accesing some other basedir other than current base we have to access that via new thread
i.e suppose i have written the code to make HttpConnection in command Action we can not access it via same thread so we ahave to create another thread and from that thread we have to call our function in which we are making HttpConnection or any RMS operation......
if(c == connectionCommand)
new Thread(new Runnable() {
public void run() {
makeConnection();
}).start();
}in this code when you are pessing connectionCommand it will create new thread and from that thread it will call makeConnaction in which we have to write code to establish connection.
i hope this will solve your problem.
Regards,
Jasmit vala.
rajputjasmit@ yahoo.co.in -
Error while trying to debug on windows mobile 6.1 with j2me SDK 3.0 ea
Hi,
I tried to debug a simple application today. It works fine with the emulator but debug fails to connect to the device.
I followed the steps described in the userguide of 3.0.
host operating system: windows xp sp3
device: htc touch pro
device operatiing system: windows mobile 6.1 professional
The device is listed in the device selector of the SDK as Touch_Pro
The device is connected and active sync is running (i can explore the phone using windows explorer)
sun-java-cldc-emu.cab has been installed on the device and is running
When i try to debug the application from the SDK or netbeans 6.5(added 3.0ea as a platform) i get the following error:
Starting emulator with port number 51307
Cannot create device connection: Failed to connect to device 9!
Result: 1
I tried setting the loglevel to DEBUG in log4j config of the SDK, but thats it.
Are there any other settings i can change to get more detailed output?
Where do you report bugs/feedback for j2me SDK 3.0 ea?
regards,
dominikg
Edited by: dominikg on Dec 11, 2008 8:36 AM
-- changed topic title to 'error' instead of 'howto'
-- added more specific questionsHi dominikg,
At first, You can try to restart the device-manager from system tray.
If it doesn't help, then try the following:
- stop the device manager
- Remove c:\Docement and Settings\<your User>\javame-sdk folder.
- Ran the device manager from <SDK>/bin directory
- try to debug again.
Did you tried to change port 51307 to another.
Early access build had some problems with device manager, I hope that final release will be better :)
BR,
Igor -
Hi All,
I am a new learner in J2ME. I m using WT2.5.2. When i press button to execute 'Hello MIDlet' program it shows
"Exception:java.lang.classNotFoundException" - this error in the Default Phone screen
and
the following ERROR shows in the Wirless Toolkit (WT) editior::
Project "HelloSuite" loaded
Project settings saved
Building "HelloSuite"
Build complete
Running with storage root C:\Users\Kalam\j2mewtk\2.5.2\appdb\temp.DefaultColorPhone2
Running with locale: English_United Kingdom.1252
Running in the identified_third_party security domain
Unable to create MIDlet HelloMIDIlet
java.lang.ClassNotFoundException: HelloMIDIlet
at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
at com.sun.midp.midlet.Selector.run(+22)
i can run the demo program but my one is not running. i copy the program from java tutorial.
Can u pls solve my problem and encourge me to work with J2ME. Thank u very much my friends.
thnx
KalamHi Darryl,
I saved this code as a "HelloMIDlet.java" in src folder of WT [and the "HelloSuite" as Midlet name, when we create project in WT u know it asks for Midlet name.
this code doesn't have compile time error.
it got runtime error cas in bin it got - HelloSuite.jd, MANIFEST.MF , there should be one more file which is .jar but it doesn't create.
i hope now u understand whts the error can u pls tell me or can u tell me the source how can i learn more about this.
thnx
kalam -
Hi,
Here is the scenario:
I have a servlet application hosted on the Tomcat webserver [ver 3.2.1] on the internet. The client midlet applicaiton is run on the j2me emulators from sun and codewarrior. The entire application works great ..
Now, a different team uses Acompli 008 over GPRS network (test env) and runs the same midlet client application. Almost evertime I see this error message on my webserver --
2001-06-21 03:42:53 - ContextManager: SocketException reading request, ignored - java.net.SocketException: Connection
reset by peer: JVM_recv in socket input stream read
at java.net.SocketInputStream.socketRead(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:86)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:186)
at java.io.BufferedInputStream.read(BufferedInputStream.java:204)
at org.apache.tomcat.service.http.HttpRequestAdapter.doRead(HttpRequestAdapter.java:115)
at org.apache.tomcat.core.BufferedServletInputStream.doRead(BufferedServletInputStream.java:106)
at org.apache.tomcat.core.BufferedServletInputStream.read(BufferedServletInputStream.java:128)
at javax.servlet.ServletInputStream.readLine(ServletInputStream.java:138)
at org.apache.tomcat.service.http.HttpRequestAdapter.readNextRequest(HttpRequestAdapter.java:129)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:195)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
I'm using httpconnection syntax, POST method for data transmission and the data size is approx 1-2K bytes.
After this error message pops on my webserver screen, the client device freezes ..
Do anyone have any ideas or suggestions or solutions ??? Is anyone aware of this or encountered this error message ??
The worst part is that i'm unable to even simulate this using the emulators ..
Thanks a lot in advance ..
S.Perhaps you could post your code on the forum so that we might be able to help you better?
Anyway, check also if you are using a get or post request from the midlet cus the Post requests have been known to give a few people problems. -
Hi:
I want to use XmlParser in my J2ME application, but at the time of defining XmlParser object i a getting error is:"XmlParser cannot be resolved to a type". I am using eclipse for developing application. I have already added KXml.zip in my src folder.
I have imported following things:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.rms.*;
import org.kxml.*;
import org.kxml.parser.*;
and actual error line is:
byte[] xmlByteArray = str.getBytes();
ByteArrayInputStream xmlStream = new ByteArrayInputStream(xmlByteArray);
InputStreamReader xmlReader = new InputStreamReader( xmlStream );
//error line XmlParser parser = new XmlParser( xmlReader );
So, can anybody help me.
Thank YouHi AnupDesai.
I'm using [kXML 2|http://kxml.sourceforge.net/kxml2/] parser, so maybe this could help you. I'm using NetBeans 6.5 and to use it I had to add the JAR file into the "resources" of my project. Then I simply use three imports:
import org.kxml2.io.KXmlParser;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;And use it like this:
KXmlParser parser = new KXmlParser();
InputStreamReader reader = (open your streeam here);
parser.setInput(reader)I hope this helps you!
Marc -
Hi,
I'm compiling many form in one J2me (java) class through the commandAction interface Out of memory Error occured . Could anyBody help me, to eliminate this Error
Thanks in advance plz help me.....
Mahesh@sunSolution: conserve memory...
Find out what is eating all your memory, and then find a way to use less.. -
JDeveloper J2ME "Configure The Extension" viewlet error
The "Configure The Extension" viewlet on the following page doesn't work.
http://otn.oracle.com/products/jdev/htdocs/partners/addins/exchange/j2me/index.html
The error message from the JRE console is:
"http://otn.oracle.com/products/jdev/htdocs/partners/addins/exchange/j2me/config.vp/Config.viewlet
java.lang.NullPointerException
at leelou.viewlet.QViewApplet.readViewlet(QViewApplet.java:129)
at leelou.viewlet.QViewApplet.<init>(QViewApplet.java:107)
at leelou.viewlet.vcr.QVCRApplet.init(QVCRApplet.java:211)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)"
I am using Internet Explorer 6.0.2800.1106, with SP1 and all subsequent updates applied. My JRE plug-in version is 1.4.2_03.
Am I doing missing something or is it a known bug? Is there any other way of accessing information about configuring the J2ME extension v9.0.3 for JDeveloper?Can you try these again now. and let us know if the problem persist?
-
Problem in J2ME application
while using Json Object in Midlet file
JSONObject obj=new JSONObject();
.Json-lib2.4-jdk15.jar added in project libraries but application shows error as
java.lang.NoClassDefFoundError: net/sf/json/JSONObject.
Project created in NetBeans 7.4Hello,
This library contains classes in the class format version 49 which is not supported by Java ME. Java ME supports class file versions up to 48 (preverify tool shall be ran against them as it was in Java ME mobile phone times) or versions 51 and greater (no preverification needed)
You might want to download source code from the SF and recompile it with javac from JDK 7 or 8 (please do not specify -target argument when compiling)
Regards,
Andrey -
J2ME Wireless Toolkit jad error
hi every1 i'm new to this j2me. i'm having the following install error:
'the application file(.jad) for HopBoy does not appear to be the correct type'.
i'm using j2me wireless toolkit. create the package then run via ota. i'm using apache web server. well i'm trying to simulate OTA function demonstrates how a mobile phone locates and downloads MIDlets from a remote server. thank u for your help.I experience the similar problem.
But got success with some mobile models and most of them fail.
I put the following file in the web page.
(test.html, test.jad, test.jar)
Sony Erisson P800, install successful when accessing http://x.x.x.x/test.html, or http://x.x.x.x/test.jar
Nokia 7650, install successful when accessing http://x.x.x.x/test.jar
Nokia 3530 Fail,
Does anyone know how to install java game to Nokia 3530 through Web. -
Error when calling method with a return of double in j2me
hello all,
i have following problem with a j2me program:
if i call a method with a return of double, then i get following error
message:
ERROR: floating-point constants should not appear
Error preverifying class test.hallo
what i'm doing wrong
thanks in regard
----------------example----------------------------
double yourValue(int y, int m, int d)
double v = 0.10;
v = 3.39 y m *d
return v;
public void startApp()
int td;
int y =2;
int m =2;
int d =2;
td = yourValue(y,m,d);
return(td);It's true for MIDP 1.0.
But you can always use implementation of the float
point arithmetic which was written by independent
developers. For example see J2ME section of my
homepage http://henson.newmail.ru
anyway, double is reserved word in java, the way you wrote the source code in your example neither the preverifier nor the compiler will recognize that you intend to use your own types for double and float. maybe with Double or Float it would be different ...
further question: you declare a void function, in the body, however, you try to return some value. something wrong with this function??
regards
bernard -
[b]Run time error in Invoking Servlet to J2ME tool kit[/b]
I am tried to invoke a servlet to my J2ME tool kit.
invoking will happen when user press command button on
the mobile phone, but when i do this there were run
time error called
"Warning: To avoid potential deadlock, operations that
may block, such asnetworking, should be performed in a
different thread than the commandAction() handler."
There are no compile errors and also i am using Jrun
webserver.
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class ServletInvoke extends MIDlet implements CommandListener
String url="http://localhost:8100/servlet/HelloServlet";
private Display dis;
private Command cmd;
private Form frm;
public ServletInvoke()
dis=Display.getDisplay(this);
public void startApp()
frm=new Form("My Project");
cmd=new Command("Click",Command.SCREEN,2);
frm.addCommand(cmd);
frm.setCommandListener(this);
dis.setCurrent(frm);
public void pauseApp()
public void destroyApp(boolean unconditional)
void invokeServlet(String url)throws IOException
HttpConnection c=null;
InputStream is=null;
StringBuffer b=new StringBuffer ();
TextBox t=null;
try
c=(HttpConnection)Connector.open(url);
c.setRequestMethod(HttpConnection.GET);
c.setRequestProperty("IF-Modified-Since","20 Jan 2001 16:19:14 GMT");
c.setRequestProperty("Content-Language","en-CA");
is=c.openDataInputStream();
int ch;
while((ch=is.read())!=-1)
b.append((char)ch);
t=new TextBox("First Servlet",b.toString(),1024,0);
finally
if(is!=null)
is.close();
if(is!=null)
c.close();
dis.setCurrent(t);
public void commandAction(Command command,Displayable dis)
if(command==cmd)
try
invokeServlet(url);
catch(IOException e)
System.out.println("IOException"+e);
//e.printStacktrace();
}PLS if can give me a working sample code as a soluation to above problem.import java.io.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class ServletInvoke extends MIDlet implements CommandListener
String url="http://localhost:8100/servlet/HelloServlet";
private Display dis;
private Command cmd;
private Form frm;
public ServletInvoke()
dis=Display.getDisplay(this);
public void startApp()
frm=new Form("My Project");
cmd=new Command("Click",Command.SCREEN,2);
frm.addCommand(cmd);
frm.setCommandListener(this);
dis.setCurrent(frm);
public void pauseApp()
public void destroyApp(boolean unconditional)
public void commandAction(Command command,Displayable dis)
if(command==cmd)
try
HTTPConnection conn = new HTTPConnection();
conn.invokeServlet(url);
catch(IOException e)
System.out.println("IOException"+e);
//e.printStacktrace();
class HTTPConnection extends Thread
String url = null;
HTTPConnection()
void invokeServlet(String url)
this.url = url;
start();
public void run()
HttpConnection c=null;
InputStream is=null;
StringBuffer b=new StringBuffer ();
TextBox t=null;
try
c=(HttpConnection)Connector.open(url);
c.setRequestMethod(HttpConnection.GET);
c.setRequestProperty("IF-Modified-Since","20 Jan 2001 16:19:14 GMT");
c.setRequestProperty("Content-Language","en-CA");
is=c.openDataInputStream();
int ch;
while((ch=is.read())!=-1)
b.append((char)ch);
t=new TextBox("First Servlet",b.toString(),1024,0);
finally
if(is!=null)
is.close();
if(is!=null)
c.close();
dis.setCurrent(t);
} -
VM Error installing J2ME Application
i am creating a J2ME application that make a HttpConnection.
I made a lot of tests in WTK and it worked fine, but when I tryi to deploy it to a iden phone Motorola i85s,
and the application is being installed, occours a VM Error.
I connected the cel phone by hyperterminal, to debug, and the following message was shown when the error appeared:
Fatal error: Unresolvable reference encountered in class services/a
I continued trying to resolve the problem and I perceived that the following line is the reason of the error:
OutputStream os = c.openOutputStream();
c is a HttpConnection object.
When i remove this line of the code, the deploy works fine... but my application needs this line to work....
Have anyone an idea about what could be happening?
Thanks a lot.Hi,
Check with your device manual if your device implementation supports HttpConnection. -
J2me run time error in developer 9052
I follow the obe
http://www.oracle.com/technology/obe/obe_as_10g/wireless/webservice/j2me.htm
After developped the application, I failed in running it.
when Click the Launch button on the phone simulator,
I got below error message in MIDlet Run window:
Unable to create MIDlet DemoPackage.DemoClass
java.lang.ClassNotFoundException: DemoPackage.DemoClass
at com.sun.midp.midlet.Selector.commandAction(+47)
at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+152)
at com.sun.kvem.midp.lcdui.EmulEventHandler$EventLoop.run(+459)
Please help me identify the reason of the error.Please provide following info for further investigation:
1> JWE version info -- you can get it from tools->preference->wireless extension panel;
2> J2ME WTK version info -- the JWE only supports Sun's WTK up to 2.0, but not 2.1 and 2.2.
Thanks,
-Jin
Maybe you are looking for
-
hi all, In my report there is an amount field and a quantity field which are need to be downloaded with 1000 separator with 2 decimal places like for eg.10,000.00 I've concatenated the workarea fields for amount and quantity on appropriate places wit
-
Customizing Login screen in OBIEE 11g
Hello All, I know how to customize login screens and Dashboard in OBIEE 10.x Versions. There are enough articles and blogs as well. But how to do customizations in 11g?. Are there any articles or forums related to it? Thanks in advance Ashok
-
Boot camp - install XP from upgrade CD
Hope to soon have a 20" iMac to replace an elderly windows tower. Wish to install XP in boot camp. My old computer was originally win98 OS. This was upgraded using a retail XP upgrade CD. I had planned to re-use this CD and do a clean install in boot
-
CSS Runs in Design, But Not Live
I added a CSS definition to "repeat-x" a 1px background image in DW CS4. I uploaded the page to my site and everything worked fine. After making a few additional changes (none to the CSS that I remember), the page stills displays correctly in design
-
Power manager questions on Windows 7
I recently installed the 3.05 version of Power manager and have a few questions. First, I used to be able to left click on the green battery bar icon once to control switching between power plans, double click to bring up the power manager, and right