File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes Please help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Please help!" Watch "Please help!" New topic
Author

Please help!

David Chan
Greenhorn

Joined: Apr 19, 2001
Posts: 21
Dear all,
I am writing a test Midlet, but don't know what wrong with it. Please help me!
I am using jdk1.3.1 and J2ME Wireless Toolkit 1.0.3 and run on Windows XP Home. The following is my program.
DemoMidlet.java
---------------
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class DemoMidlet extends MIDlet implements CommandListener{
private Form welcomeForm;
private Alert alert;
private Display display;

private Command okCmd = new Command("Ok", Command.SCREEN, 5);
private Command cancelCmd = new Command("Cancel", Command.CANCEL, 10);

public DemoMidlet() {
display = Display.getDisplay(this);
}
public void startApp() {
System.err.println("start startApp");

welcomeForm = new Form("Welcome");
welcomeForm.addCommand(okCmd);
welcomeForm.addCommand(cancelCmd);
welcomeForm.setCommandListener(this);
display.setCurrent(welcomeForm);
System.err.println("end startApp");


}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {

if (d == welcomeForm) {

System.err.println("It is running ... ");
}

}

}
MANIFEST.MF
-----------
Manifest-Version: 1.0
MIDlet-Name: Demo
MIDlet-1: Demo, ,DemoMidlet
MIDlet-Version: 1.0
MIDlet-Vendor: Samuel
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-1.0
Demo.jad
----------
MIDlet-Version:1.0
MIDlet-Vendor:Samuel
MIDlet-Jar-URL emo.jar
MicroEdition-Configuration:CLDC-1.0
MicroEdition-Profile:MIDP-1.0
MIDlet-1 emo, ,DemoMidlet
MIDlet-Name emo
MIDlet-Jar-Size:290

Compile.bat
-----------
javac -bootclasspath %J2ME_HOME%\lib\midpapi.zip -sourcepath D:\FYP\Test -classpath D:\FYP\Test -target 1.1 *.java
%J2ME_HOME%\bin\preverify.exe -classpath %J2ME_HOME%\lib\midpapi.zip;. -d D:\FYP\Test D:\FYP\Test
%JAVA_HOME%\bin\jar cmf MANIFEST.MF Demo.jar *.class
Run.bat
-------
set CLASSPATH=%J2ME_HOME%\lib\midpapi.zip;%J2ME_HOME%\wtklib\kvem.jar;%J2ME_HOME%\wtklib\kenv.zip;%J2ME_HOME%\wtklib\lime.jar
%J2ME_HOME%\bin\emulator -Xdescriptor :\FYP\Test\Demo.jad
When I run it with run.bat, the following error occurs:
Error verifying method DemoMidlet commandAction(Ljavax/microedition/lcdui/Comman
d;Ljavax/microedition/lcdui/Displayable V
Approximate bytecode offset 5: Inconsistent or missing stackmap at targetExecuti
on completed successfully
64061 bytecodes executed
8 thread switches
311 classes in the system (including system classes)
630 dynamic objects allocated (27784 bytes)
ALERT: Error verifying class DemoMidlet
2 garbage collections (14720 bytes collected)
Total heap size 500000 bytes (currently 482840 bytes free)
Please help me! I really don't know how to fix it.
Thanks
David Chan
David Veszelovszki
Greenhorn

Joined: Jul 12, 2002
Posts: 1
I have EXACTLY the same problem. And I use Windows XP, too. I tryed to pre-verify a _very_ simple program, too, and it was complited without any problems (SDK 1.4.0), but the pre-verification couldn't be done. Please help me! I think I may need an XP-compatible version of preverify.exe.
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Originally posted by David Veszelovszki:
I have EXACTLY the same problem. And I use Windows XP, too. I tryed to pre-verify a _very_ simple program, too, and it was complited without any problems (SDK 1.4.0), but the pre-verification couldn't be done. Please help me! I think I may need an XP-compatible version of preverify.exe.

You have a different problem than David Chan. Chan can pre-verify his program and the emulator VM could not handle the pre-verified code.
You cannot preverify your class files. I tends to remember there is a preverify problem if you compile your classes using J2SE 1.4. I do not know about widnwos xp but it is the case for Linux. So, try 1.3.1.


Seam Framework: http://www.amazon.com/exec/obidos/ASIN/0137129394/mobileenterpr-20/
Ringful: http://www.ringful.com/
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Originally posted by David Chan:

Compile.bat
-----------
javac -bootclasspath %J2ME_HOME%\lib\midpapi.zip -sourcepath D:\FYP\Test -classpath D:\FYP\Test -target 1.1 *.java
%J2ME_HOME%\bin\preverify.exe -classpath %J2ME_HOME%\lib\midpapi.zip;. -d D:\FYP\Test D:\FYP\Test
%JAVA_HOME%\bin\jar cmf MANIFEST.MF Demo.jar *.class

David Chan,
It seems that you put the pre-verified classes back to the original directory and overwrite the existing class files? That might be the problem?
Again, this is only a suggestion. I do not use windows.
a sanjuan
Ranch Hand

Joined: Jun 12, 2002
Posts: 164
that midlet runs on windows XP using Sun's wireless toolkit 1.03.
http://www.blueboard.com/phone/demo_midlet.gif
i've also seen where the source classes are in the same directory as the preverified classes, so i dunno.
i've never seen that command for running the emulator in the run.bat...was this from a book?
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Originally posted by a sanjuan:

i've never seen that command for running the emulator in the run.bat...was this from a book?

That one is correct and it is from the J2MEWTK documentation.
Actually, I wrote a piece about
How to Combine J2MEWTK with ANT
in an IBM developerWorks MIDP forum I host. It discusses how to take advantage of both command line tools and IDE tools in J2ME development.
The forum does not have much traffic. JavaRanchers are all welcome to discuss there.
a sanjuan
Ranch Hand

Joined: Jun 12, 2002
Posts: 164
which just goes to show i'm the typical consumer who doesn't read the included documentation, much to the chagrin of customer care departments everywhere...
Ivan Poza
Greenhorn

Joined: Oct 28, 2003
Posts: 2
I get the same error:
Error verifying method DemoMidlet commandAction(Ljavax/microedition/lcdui/Comman
d;Ljavax/microedition/lcdui/Displayable V

I�m compiling my midlet in Sun One Studio 4 Update 1.
The fact is that with the option "Preverier Compiler" works in the Java Wireless Toolkit 1.0.4 (default toolkit).
But when changing the compiler to "NSDJ2ME Compiler" the above error is raised. (I need the midlet to compile with this compiler cause it is needed to prove it in all Nokia emulator devices that are provided with Nokia Developer Suite 2.0)
If someone had the same error and solved it, pliz tell me the way to get it right. Thanx!
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
You can run WTK preverified classes on Nokia devices. So, you do not need the Nokia preverify program. Just the emulators from NDS would be enough for you.
Ivan Poza
Greenhorn

Joined: Oct 28, 2003
Posts: 2
Even using the preverifyer compiler on Sun One Studio 4 upd1. and Nokia 7210 emulator to test it I get the error which can be sown below.
Nokia 7210 MIDP SDK v1.0: Emulator command: D:\Nokia\Devices\Nokia_7210_MIDP_SDK_v1_0\bin\7210.exe -parent_port 2810 -language English -classpath "D:\Nokia\Devices\Nokia_7210_MIDP_SDK_v1_0\lib\classes.zip;D:\Mis documentos\u443u391\Clientes\MIDP\XMLMidlet.jar" "D:\Mis documentos\u443u391\Clientes\MIDP\XMLMidlet.jad"
Nokia 7210 MIDP SDK v1.0: Error verifying method XMLMidlet commandAction(Ljavax/microedition/lcdui/Command;Ljavax/microedition/lcdui/Displayable V
Nokia 7210 MIDP SDK v1.0: Approximate bytecode offset 5: Inconsistent or missing stackmap at target
Nokia 7210 MIDP SDK v1.0: Error verifying class XMLMidlet

Any solution for this one?? (I think it�s the same that using NDSJ2ME compiler, another compiler but the same error message)
Carlos Quiroz
Greenhorn

Joined: Oct 27, 2003
Posts: 14
Hi
For maximum compatiblity with the Nokia emulators do the compilation setting the target as 1.2
Something like javac -target 1.2 -classpath ....
Regards
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Originally posted by Carlos Quiroz:
For maximum compatiblity with the Nokia emulators do the compilation setting the target as 1.2
Something like javac -target 1.2 -classpath ....

Thanks Carlos. I have always just used the command line default options. I guess the IDE must be doing -target 1.1 to avoid an earlier compatibility problem with the JDK 1.4.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please help!
 
Similar Threads
JME Hello World
Some more Mock questions #1 For me
Preverify on Windows and Linux differ? PROBLEM
How to write to a file?
commandAction - newbie