• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Please help!

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Michael Yuan
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic