Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to locate package java.lang

 
Martin Felando
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't seem to get past the setup phase. I downloaded J2sdk1.4.2 and midp 1.0 following instructions in a "J2ME Game Programming" book. I made path, midp_home, classpath changes and I think therein lies the problem - I just don't understand the fundamentals.

I preverified and the midp emulator is available, but when I compiled and ran the midlet the message "Hello, Micro World!" didn't show up. The emulator showed up but the screen had no message and the only command that worked was "quit".

I saved code and used "javac -target 1.1 -bootclasspath %MIDP_HOME%\classes Hello.java" and getting "unable to locate package java.lang" error messages. I reentered some classpath and path data and this got me to the empty emulator but this quick fix doesn't inspire self confidence.

Earlier, when I preverified the class file entering "preverify -cldc -classpath %MIDP_HOME%\classes;. -d . Hello" I was getting
"Error preverifying class Hello
java/lang/NoClassDef Found Error: javax/microedition/lcdui/CommandListener"

I'd like to know what those errors meant, why the Hello, Micro World message didn't show up on the emulator, and how to properly setup environment variables classpath, path, and midp.

with kind regards,
mf
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know MIDP, perhaps you find something in 'Other java APIs'.

Why do you use '-target 1.1'? Is this recommended for midp?
Is 'javax/microedition' part of 1.1?

On Windows:

paste the settings.txt here.
 
Martin Felando
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm quoting from the book: "The -target 1.1 is there due to a known issue when using JDK 1.4 and the MIDP preverifying tool. If you compile normally you see a Class loading error: Illegal constant pool index error when you attempt to preverify later. To avoid this, you force the Java compiler to output class files in the older 1.1 version format. If you're using a version of the MIDP later than 1.03, feel free to give things a go without this option."

I hope that helps. I don't know what to do with your instructions per "ECHO PATH..." etc. How do I begin to input the data? Where do I start?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic