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

simple code not working from tutorial

 
Anjanesh Lekshminarayanan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I'm trying to learn j2me and found this nice tutorial (http://www.zindell.com/israeliJavaBookME/ch1.htm) from this forum but it was written in 2001.
There is this simple code :

The tutorial gave this commandline :
javac -bootclasspath c:\j2mewtk\lib\midpapi.zip HelloIsrael.java
but obviously this was in version 1. I have version 2 and so I gave this :
javac -bootclasspath c:\WTK21\lib\midpapi10.jar HelloIsrael.java
I also tried midpapi20.jar but both tries gave these 2 errors:

HelloIsrael.java:3: cannot access java.lang.Object
file java\lang\Object.class not found
public class HelloIsrael extends MIDlet
^
HelloIsrael.java:10: cannot resolve symbol
symbol : variable this
location: class HelloIsrael
display = Display.getDisplay(this);
^
2 errors

Can anyone help me out here ? I am running form bin directory.
Thanks
 
Arnab Sen
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there...

post your CLASSPATH and PATH variables...
 
Anjanesh Lekshminarayanan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I tyed path it gave. i know java is not listed but I normally run my java files from the bin folder directly.
PATH=C:\WINDOWS\system32;C:\WINDOWS;

Otherwise how else do I retrieve classpath & path ?

Java is in C:\j2sdk1.4.1_02\bin and j2me in C:\WTK21
 
Anjanesh Lekshminarayanan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did this :
javac -bootclasspath c:\wtk21\lib\midpapi20.jar,C:\WTK21\lib\cldcapi11.jar -classpath C:\Progra~1\Java\j2re1.4.2_04\lib HelloIsrael.java

Changed classpath to this too : classpath C:\j2sdk\lib

I am getting this always :
Fatal Error: Unable to locate package java.lang in classpath or bootclasspat
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to point the classpath to the .jar files, not the directory where the .jar files are located in.
 
Anjanesh Lekshminarayanan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which jar file(s) are you talking abt ? The one with J2ME or J2SE ? Also which one is the one that contains java.lang.io ?
Thanks
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anjanesh Lekshminarayanan:
Which jar file(s) are you talking abt ? The one with J2ME or J2SE ? Also which one is the one that contains java.lang.io ?
Thanks

Both.

java.lang.* and java.io.* are part of J2SE's "tools.jar".
 
Rashi Gulati
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Anjanesh

It would be better if you use j2me wireless toolkit, then atleast you save yourself from running the application from command prompt, it will take care of your classpath as well. If you need the url to download the kit i will post the url.

Regards
Rashi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic