Solved

MIDP preverification snag: "java/lang/NoClassDefFoundError: javax/microedition/lcdui/CommandListener"

Posted on 2004-08-16
9
1,390 Views
Last Modified: 2013-11-24
Java MIDP applications must be preverified before they can be executed on target devices.  (See http://developers.sun.com/techtopics/mobility/midp/articles/setup/#compile.)

While attempting to preverify \\midp2.0fcs\src\example\HelloMIDlet.java (which compiles just fine), I get the following error:

"Error preverifying class HelloMIDlet
    java/lang/NoClassDefFoundError: javax/microedition/lcdui/CommandListener"

This is odd, considering javax/microedition/lcdui/ (which does indeed contain CommandListener.class) is a subfolder of my classpath.  (If it wasn't, then the HelloMIDlet.java source obviously wouldn't have compiled in the first place.)

I did a search and found that the problem dates back to the year 2000.  (Nice.)  The only solution I found -- unpacking a midp.jar file and directing the classpath to a folder with its contents -- is no good, since there is no midp.jar file.

Has anyone successfully compiled HelloMIDlet.java?  What is the solution to the java/lang/NoClassDefFoundError: javax/microedition/lcdui/CommandListener problem?
0
Comment
Question by:MiloDC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 11808515
How do you compile it? Do you specify the classpath on the command line? If yes then you will also need to specify the classpath upon verification.
0
 

Author Comment

by:MiloDC
ID: 11808607
> girionis wrote:

> How do you compile it? Do you specify the classpath on the command line? If yes then you will also need to specify the classpath upon verification.

I do indeed specify the classpath during compilation and preverification.  Specifically:

Compile:
javac -bootclasspath C:\midp2.0fcs\classes -deprecation -g -d "TmpClasses" -classpath C:\j2sdk1.4.2_05\lib\tools.jar;C:\j2sdk1.4.2_05\lib\;C:\midp2.0fcs\classes\;. HelloMIDlet.java

Preverify:
preverify -cldc -classpath C:\j2sdk1.4.2_05\lib\tools.jar;C:\j2sdk1.4.2_05\lib\;C:\midp2.0fcs\classes\;. TmpClasses -d "Classes"

Nevertheless, I get the error upon preverification.

Very odd.

0
 
LVL 35

Expert Comment

by:girionis
ID: 11808626
> Nevertheless, I get the error upon preverification.

Hmm.. You might not be able to use the -classpath switch with preverification. Can you do a preverify -help (or preverify --help)? YOu will probably get all the available switches that you can use with preverify.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:MiloDC
ID: 11808928
> girionis wrote:

> You might not be able to use the -classpath switch with preverification.

-classpath is a valid option.  This is confirmed in the documentation from Sun Microsystems.
0
 
LVL 35

Accepted Solution

by:
girionis earned 125 total points
ID: 11809028
Weird, can you try that one:

preverify -cldc -classpath C:\j2sdk1.4.2_05\lib\tools.jar;C:\j2sdk1.4.2_05\lib\;C:\midp2.0fcs\classes;. TmpClasses -d "Classes"

(note that classes folder does not have a \ at the end). Not sure if this will help though.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11809046
Can you also tell me if this class:

javax/microedition/lcdui/CommandListener is in a jar file or not? What happens if you put that jar file in the classpath?
0
 
LVL 18

Expert Comment

by:armoghan
ID: 11810029
I use IDE JBuilderX. You can also download the trial version from JBuilder Site. It has 5-6 sample projects including HelloMIDlet.java. Just run them using the IDE. I just changed the classpath a littlebit and they run fine in the emulator. .Jad files are also automatically made. I just sink them and they are running fine on my PocketPC
0
 

Author Comment

by:MiloDC
ID: 11812011
Thanks for the answer, girionis.  :)

The slash after "C:\midp2.0fcs\classes" was the culprit.  How lame.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11812058
Well, computing is a bizarre field, even a little dot counts :)

Thank you for accepting, glad I was of help :)
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert from a json string array to a Java object 3 64
Java: The Public Class Main 4 45
java example issue 5 46
How to configure empty element in XML Document parser? 15 45
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question